CEGUI getID error

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
J_A_X
Quite a regular
Quite a regular
Posts: 72
Joined: Wed Jun 29, 2005 13:18
Contact:

CEGUI getID error

Postby J_A_X » Wed Aug 17, 2005 21:18

So I got this code:

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.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: CEGUI getID error

Postby CrazyEddie » Thu Aug 18, 2005 13:35

You'd probably be better off using the TabControl methods to access the 'active' page, as opposed the the low-level Window stuff - which in this case may return a Window other than the container window for a content pane.

Use: TabControl::getSelectedTabIndex to get the index of the active tab, and then TabControl::getTabContentsAtIndex to get the content of that tab.

User avatar
J_A_X
Quite a regular
Quite a regular
Posts: 72
Joined: Wed Jun 29, 2005 13:18
Contact:

Re: CEGUI getID error

Postby J_A_X » Thu Aug 18, 2005 18:26

*sigh*

I must be bug prone or something cause it keeps crapping out on me.

What you said helped me for the bit of code that was erronous before, but it just made other errors.

I think there is something very flawed with the tabControl which you should look into. More specifically, the addTab and removeTab function. All my tabs are added with the addTab function since all the tabs can be added at runtime. It can also be removed at runtime with the removeTab function. One little problem though is this:

Code: Select all

// Remove Tab       tabControl->removeTab(tabControl->getSelectedTabIndex());


Nothing complicated, it just takes the ID of the currently selected tab to be removed right?

Well, this is the exception thrown at me:

18/08/2005 14:19:27 (Error) Exception: Window::getChild - The Window with ID: '1' is not attached to Window 'SADTabControl__auto_TabPane__'.


Now, I know the tab has been added to the tabControl cause I can see it, click on it and it even shoots off events. The reason I never used addChildWindow function to add tabs in the tab control is after the first was added (during runtime, which worked fine), the second that was trying to get added would throw and exception which I though addTab would fix, which it did, but now has this problem...

I'm jinxed, stay away from me...

User avatar
J_A_X
Quite a regular
Quite a regular
Posts: 72
Joined: Wed Jun 29, 2005 13:18
Contact:

Re: CEGUI getID error

Postby J_A_X » Thu Aug 18, 2005 18:55

I just tried using removeChildWindow. It works, but the tab still stays there and of course returns and error when trying to click on the tab...this is too confusing...

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: CEGUI getID error

Postby CrazyEddie » Fri Aug 19, 2005 13:13

The method getSelectedTabIndex() returns an index and not an ID, which is likely the root of this latest issue. So you'll probably end up adding some extra calls to obtain the content via it's index (using getTabContentsAtIndex() ), and then getting the ID from there.

The TabControl was contributed by Sinbad who created it specifically for a project he was working on. There are areas that could use improvement, as is the case with any of the widgets, though if this had not been contributed the system would likely not have a tab control at all, so we should be grateful for such contributions and be prepared to contibute further work to improve them as required - that's the whole point of this being open source, not so that I can sit here and do it all myself ;)

User avatar
J_A_X
Quite a regular
Quite a regular
Posts: 72
Joined: Wed Jun 29, 2005 13:18
Contact:

Re: CEGUI getID error

Postby J_A_X » Fri Aug 19, 2005 14:43

Gotcha. Well, I guess i'm going to have to do changes in that widget then. If i get everything working, I'll be sure to post the patch. Is there a specific patch template/protocol or something I should use or just post the code?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: CEGUI getID error

Postby CrazyEddie » Sat Aug 20, 2005 18:08

Patches should be in the form of a unified 'diff' as produced by using the command:

Code: Select all

cvs diff -u

- or -

Code: Select all

diff -u

within the cegui_mk2 directory.

So, you basically redirect the output of one of these commands to a file and submit the file on the patch tracker along with a description of what it's supposed to do, and any other relevant information.

Anything other than diffs are of little or no use since it's too easy for other recent changes to get lost or reversed. We really need the 'unified' format since these are much more useful to see what's going on and enables us to apply them even when the target files have significantly changed.

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: CEGUI getID error

Postby Van » Wed Sep 21, 2005 16:31

I am having the same issue with the removeTab. Neither the remove by name or the remove by window id appear to work. If I destroy the window, the tab remains and then all hell breaks loose when you select that tab. :(

CrazyEddie wrote:
The method getSelectedTabIndex() returns an index and not an ID, which is likely the root of this latest issue. So you'll probably end up adding some extra calls to obtain the content via it's index (using getTabContentsAtIndex() ), and then getting the ID from there.


I tried this, but it still doesn't work. It always removes the FIRST tab.

Code: Select all

   // Find the TAB - if it exist.
   mNumItems = mTabControl->getTabCount();
   for (c = 0; c < mNumItems; c++ )
   {
      CEGUI::Window *mWin = mTabControl->getTabContentsAtIndex(c);
      mStr = mWin->getText();
      if ( mStr == mChannelName ) 
      {
         mTabControl->removeTab( mWin->getID() );
         break;
      }
   } // for




CrazyEddie wrote:
The TabControl was contributed by Sinbad who created it specifically for a project he was working on.


*phew*. Now we know who to blame... I am going to email Sinbad and find out when he is going to fix it. :twisted:

User avatar
Van
Just can't stay away
Just can't stay away
Posts: 225
Joined: Fri Jan 21, 2005 20:29
Contact:

Re: CEGUI getID error

Postby Van » Wed Sep 21, 2005 16:50

OK, I got it to work..

What wasn't apparent to me until I look at the TabControl source code is that when you attempt to removeTab by using the NAME, you must use the DefaultWindow window name.

that is:

Code: Select all

// Create the new TAB
sprintf(mTemp, "Chat/Channel/%s", mChannelName );
mChan->Tab = CEGUI::WindowManager::getSingleton().createWindow( (CEGUI::utf8*)"DefaultWindow", (CEGUI::utf8*)mTemp );
mChan->Tab->setText( (CEGUI::utf8*)mChannelName );
mChan->Tab->setSize(CEGUI::Size(1.0f, 1.0f));
mChan->Tab->setPosition(CEGUI::Point(0.00f, 0.0f));
mTabControl->addTab(mChan->Tab);


and remove it by doing something like:

Code: Select all

// remove the tab
if ( mChan->Tab )
{
   sprintf(mTemp, "Chat/Channel/%s", mChannelName );
   mTabControl->removeTab( mTemp );
}


This works.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 7 guests