I have been scratching my head for hours trying to figure out why this is crashing.
This is what it basically does.
I have a gui component called Table. I need 1000 tables. No more, no less. Table inherits from Widget and DynamicElement at the same time. I need to be able to pass around the address of the component (the pointer, not a copy) so I need them not to move.
The first attempt I did worked. I used a vector of Table* and each of the tables were separately allocated on the heap. This method is a bit slow and risks fragmenting the heap for nothing because I need exactly 1000.
The next solution I came up with is for the parent class to have Table m_tables[1000].
I see no reason why this should not work, but when I do it like this, it crashes. In fact, any time I seem to try to do something involving &m_tables[x] something goes wrong.
It crashes with 0xccccccccc violation whenever something tries to access the pointer obtained by doing &m_tables[i].
Is there something I am not understanding?
Here is how I create a table:
void LobbyTableManager::createTable( int tableId )
{
m_tables[tableId] = LobbyTable(m_fontMan,m_spriteMan,tableId);
LobbyTable* t = &m_tables[tableId];
t->addChairActionListeners(this);
t->addMouseListener(this);
t->addChairMouseListeners(this);
t->getTable()->addMouseListener(this);
t->rescale(1.0f);
m_activeTables.push_back(t);
//rescaleTables();
m_flow->add(t);
resizeFlow();
updateScrollBars();
}
I add the table to the flow layout and the second it tries to use it it crashes.
I tried using a std list which should theoretically produce the same result as my first attempt but that crashes too.
Thanks
VC Debug builds initialize uninitialized variables with 0xCCCCCCCC.
(list of special values)
Start the program under the debugger so you can see on which line of code that happens. If it’s not your code, go up the call stack until you are inside “your” code.