Cleanly deleting PLSM2 SceneManager

pra

24-07-2007 14:55:24

Ok, another problem:

-i use a "level" class which contains primarily a scenemanager and a ogrenewt world. it is loaded from a xml file, and decides itself if the scenemanager should be general oder PLSM2
-the player should be able to move between levels, level change usually happens during FrameStarted
-to change a level, i create a new one and delete the old one right after that.

the problem is: after a plsm2 level is loaded (and unloaded) several times, the app breaks at this line:
mRoot->startRendering();

-if the level should be plsm2, it does this:
mSceneMgr = app->getRoot()->createSceneManager("PagingLandScapeSceneManager");
String src = elem->Attribute("src");
String mapName = "";
//XML stuff...
if(elem->Attribute("mapName"))
{
mapName = elem->Attribute("mapName");
}
DataStreamPtr stream = ResourceGroupManager::getSingletonPtr()->openResource(src,"PLSM2");
mSceneMgr->setWorldGeometry(stream);
//several delegate stuff removed for testing, it didn't affected the problem

mSceneMgr->getOption("CurrentMap",&plsm2MapName);
if(mapName != "" && plsm2MapName != mapName)
{
//load map
mSceneMgr->setOption("CurrentMap",&mapName);

}
mSceneMgr->setOption("LoadMap",0);
mSceneMgr->setOption("LoadNow",0);
Real lms = 0.02;
mSceneMgr->setOption("LODMorphStart",&lms);

-in level destructor, following code takes care of the scene manager:
mSceneMgr->destroyAllCameras();
mSceneMgr->clearScene();
app->getRoot()->destroySceneManager(mSceneMgr);


now, what do I forget? do I have to do something special to destroy a plsm2 scenemanager before creating another one?