Bug in TreeControl

simed

24-11-2011 13:09:08

I've been using TreeControl for a bit but I think I found a bug. I have a tree as a child of a window and when I delete the parent window, I get a crash. Stack trace is:> simed_d.exe!MyGUI::TreeControl::Node::prepare() Line 43 + 0x3 bytes C++
simed_d.exe!MyGUI::TreeControl::Node::prepareChildren() Line 54 C++
simed_d.exe!MyGUI::TreeControl::notifyFrameEntered(float nTime=0.022000000) Line 217 + 0xe bytes C++
simed_d.exe!MyGUI::delegates::CMethodDelegate1<MyGUI::TreeControl,float>::invoke(float p1=0.022000000) Line 116 + 0x1d bytes C++
MyGUIEngine_d.dll!MyGUI::delegates::CMultiDelegate1<float>::operator()(float p1=0.022000000) Line 325 + 0x23 bytes C++
MyGUIEngine_d.dll!MyGUI::Gui::frameEvent(float _time=0.022000000) Line 349 C++
MyGUIEngine_d.dll!MyGUI::RenderManager::onFrameEvent(float _time=0.022000000) Line 64 C++
simed_d.exe!MyGUI::OgreRenderManager::renderQueueStarted(unsigned char queueGroupId='d', const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & invocation="", bool & skipThisInvocation=false) Line 195 + 0x33 bytes C++
I've checked and the TreeControl IS destroyed - TreeControl::mpRoot == 0xfeeefeee. So the crash is because TreeControl::Node doesn't exist but a method is called on it. It seems like for some reason, MyGUI doesn't remove the TreeControl from the list of renderable widgets (other Widgets are not giving the same issue). But I would expect that to be low-level functionality of Widget so I'm a bit confused.

Can anyone advise... I know TreeControl is still in development but some kind of workaround is really needed if the bug is in MyGUI code?

simed

24-11-2011 15:21:46

Well, I found a fix but I don't really know it's ideal.

In TreeControl::shutdownOverride (which I assume is the equivalent of virtual destructor) I add this just before Base::shutdownOverride():Gui::getInstance().eventFrameStart -= newDelegate(this, &TreeControl::notifyFrameEntered);

shenjoku

02-12-2011 01:17:37

How are you using this widget? As far as I can tell there's not a single source file for it except in the UnitTest_TreeControl folder. It doesn't look like it's part of the actual engine.

simed

02-12-2011 08:40:20

That's right, for some reason they seem to put WIP functionality in unit-tests section. We just copied the tree control files from there into our own project and made some slight modifications.
I imagine it will be part of main engine eventually, when more complete...

Altren

02-12-2011 11:15:42

No, it probably won't be part of main engine. This widget is too complex to keep things clear enough. We are trying to not include complex widgets into core if possible, because otherwise we will end with lots of (probably half working) widgets and a huge engine, which is very hard to support. As for this particular widget - it was written by one of MyGUI users and he shared code with us, this is more of example than complete widget, so it might require some tweaks.

What about your problem - try to add two lines in the beginning of TreeControl::shutdownOverride:
void TreeControl::shutdownOverride()
{
if (mbInvalidated)
Gui::getInstance().eventFrameStart -= newDelegate(this, &TreeControl::notifyFrameEntered);

simed

02-12-2011 11:35:59

Hmm, I would have thought a GUI library needs standard controls to be useful. Or do you mean you're happy to work on a wider range of controls, but keep them like addons rather than in core library?

Ogre is getting quite a lot of non-game use, and I could see MyGUI being a really strong choice for this.