MyGUI in a multi-thread framework & problems


06-10-2008 07:27:34


The problem will be hard to explain :D

I am part of the OGE team ( and we are trying to create a multi-thread framework and I would like to load MyGUI as a plugin.

This plugin will be in another thread than the graphics one.
I know that MyGUI is perhaps not thread-safe but I will try anyway by making small steps first.

For now I only create and shutdown the mGUI it works fine.

Except I had to make a small change in the code.

In MyGUI_Gui.cpp I had to comment out the line 134 to avoid a segfault at shutdown:
//_ delete mFontManager;

Uncommenting this line will cause a segfault even if the MyGUI log will show that the managers did shutdown correctly:

14:57:32 | General | Info | LayerManager successfully shutdown | .\src\MyGUI_LayerManager.cpp | 65
14:57:32 | General | Info | * Shutdown: FontManager | .\src\MyGUI_FontManager.cpp | 36
14:57:32 | General | Info | FontManager successfully shutdown | .\src\MyGUI_FontManager.cpp | 40
14:57:32 | General | Info | * Shutdown: ControllerManager | .\src\MyGUI_ControllerManager.cpp | 31

However there is a segfault in Ogre:

Here is the callstack

[Frames below may be incorrect and/or missing, no symbols loaded for boost_thread-vc80-mt-1_34_1.dll]
OgreMain.dll!Ogre::ResourceGroupManager::_notifyAllResourcesRemoved(Ogre::ResourceManager * manager=) Line 923 + 0x12 bytes C++
OgreMain.dll!Ogre::ResourceManager::removeAll() Line 313 C++
OgreMain.dll!Ogre::ResourceManager::~ResourceManager() Line 52 C++
> MyGUI.dll!MyGUI::FontManager::`vector deleting destructor'() + 0x51 bytes C++
MyGUI.dll!MyGUI::Gui::shutdown() Line 134 C++

My opinion is that the FontManager is destroyed to soon. In other words before the resources were totally unloaded.

Any idea how to avoid this ?