Code: Select all
void TabManager::removeTab(){
if(tabIndex>1){
// Delete Grid and tab
gridArray[selectedTab]->hide();
tabControl->removeTab(tabArray[selectedTab]->getID());
// Reorganize tab & grid array
for(int i = selectedTab;i<Constant::CFG_MAX_TABS-1;i++){
tabArray[i] = tabArray[i+1];
gridArray[i] = gridArray[i+1];
}
tabIndex--;
if(tabIndex < Constant::CFG_MAX_TABS){
newTab->enable();
}
if(tabIndex==1){
tabClose->disable();
}
// Finds out which tab is selected and show appropriate Grid
CEGUI::uint tmp = tabControl->getActiveChild()->getID();
for(int x = 0; x<tabIndex;x++){
if(tabArray[x]->getID() == tmp){
selectedTab = x;
gridArray[x]->show();
break;
}
}
}
}
In a nutshell, it takes the currently selected tab and removes it from tabControl, hides the grid corresponding to the tab, then deletes the 2 instances of the grid and tab in the array for more to be put in.
The problem in this code is the last part of it where it is suppose to find out which tab is activated AFTER the selected tab has been deleted. When it calles the getActiveChild()->getID(), it gives me this error:
First-chance exception at 0x005b25e6 (CEGUIBase_d.dll) in PCTGUI.exe: 0xC0000005: Access violation reading location 0x000000dc.
I have nothing in the CEGUI log that's helpful. I thought it was because CEGUI didn't specify the activeChild after the deletion of the last one, but I looked at the code and it is suppose to do so...
I know this must take time to go into and all, but if I just find out what's the algorithm behind the activechil selection, I could code around it so it doesn't have to call the getActiveChild() function and give me this error.