[Fixed] myGui crashing with multiple scene managers

jonathanc

30-03-2009 18:12:47

Hi, I am having problems with myGUI->setSceneManager.

I initialise myGUI in my IntroState and set it to the scenemanager. When I change state to PlayState I destroy the first scene manager and create a new scenemanager. However, in PlayState if I try to set it to the newly created scene manager my GUI just crashes.

Any ideas why?

andrewfenn

30-03-2009 20:31:31

I had this problem too, I'd get the following error..

x <= max.x && min.y <= max.y && min.z <= max.z) && "The minimum corner of the box must be less than or equal to maximum corner"' failed.

The way I fixed it was to set the scene manager in MyGUI before creating a new camera.

jonathanc

30-03-2009 21:00:13

Fixed!

I got that problem earlier too but the solution is pretty simple.

Do not destroy the previous SceneManager before you set to the new manager. Destroy it after that. I destroyed the SceneManager for IntroState upon change state and same for PlayState. So it works fine for the first "cycle" but upon entering IntroState again and try to set the sceneManager from PlayState to IntroState it crashes because PlayState does not exist anymore.

So in conclusion, for multiple SceneManagers, the old one you are changing from must exist prior to setting it to a new one!

andrewfenn

31-03-2009 00:03:22

After posting I realised that actually my program was now randomly crashing instead of crashing all the time. After reading what you said it makes sense now. Anyway, I made a patch which seems to fix the problem for me.

Index: MyGUIEngine/src/MyGUI_LayerManager.cpp
===================================================================
--- MyGUIEngine/src/MyGUI_LayerManager.cpp (revision 1862)
+++ MyGUIEngine/src/MyGUI_LayerManager.cpp (working copy)
@@ -248,7 +248,7 @@

void LayerManager::setSceneManager(Ogre::SceneManager * _scene)
{
- if (nullptr != mSceneManager) mSceneManager->removeRenderQueueListener(this);
+ if (nullptr != mSceneManager && isExist(mSceneManager->getName())) mSceneManager->removeRenderQueueListener(this);
mSceneManager = _scene;
if (nullptr != mSceneManager) mSceneManager->addRenderQueueListener(this);
}

Altren

31-03-2009 00:39:17

Ha-ha, nice fix. I'll tell you what your code do: isExist function check if layer with such name exist, layer names is "Back", "Overlapped", "Main" and so on. Of course there's no such layer and isExist always return false, so your fix is same as writing
Index: MyGUIEngine/src/MyGUI_LayerManager.cpp
===================================================================
--- MyGUIEngine/src/MyGUI_LayerManager.cpp (revision 1862)
+++ MyGUIEngine/src/MyGUI_LayerManager.cpp (working copy)

void LayerManager::setSceneManager(Ogre::SceneManager * _scene)
{
- if (nullptr != mSceneManager) mSceneManager->removeRenderQueueListener(this);
mSceneManager = _scene;
if (nullptr != mSceneManager) mSceneManager->addRenderQueueListener(this);
}
I'll try to fix it anyway. May be add some function that says than old scene manager already dead.

andrewfenn

31-03-2009 03:21:30

Ah! Thanks for pointing that out. :D