M@gg!
28-08-2006 10:36:54
I create a body within a Frame Listener Class and want to delete it during the running scene. The class shall be deleted to.
So I'v written a destructor for the class as following:
Ogre::Root::getSingleton().removeFrameListener(this);
mBdyBody->mNode->removeChild(mNodParticleSystem);
mNodParticleSystem->detachObject(mParticleSystem);
mSceneManager->destroyParticleSystem(mParticleSystem);
mNxSceneManager->destroyBody(mName);
While the program is runing it works. But when the Ogre::Root is deleted, I get a seg fault.
betajaen
28-08-2006 12:11:40
Hmm thats really really odd.
I've deleted bodies within frameListeners before, in Tutorial 116 as you create more bodies using the space bar if it reaches the soft-limit of 75 it calls the a scene function to delete bodies older than 30 seconds.
More or less it's the same code.
A naughty way of doing it is via "delete mBody;" see if that works?
However if your just switching levels, or in between scenes. Why just not delete the scene?
M@gg!
28-08-2006 12:49:20
It's not during changing between two scenes. I'm deleting old projectiles this way. This is the reason why I'm programming the Magazine Storage...
With normal delete it works neither.
betajaen
28-08-2006 23:47:41
Right, I may have down the error, and squashed a nasty bug as well.
I was working on my own project and I wanted to delete a list of scenes by hand then delete world. It deletes the scene fine, but then world crashes. Reporting that there is still 1 scene around to be deleted.
Turns out I forgot to erase that scene from the mScene vector in World, causing it to think that there is still 1 scene around, pointing to some cleared memory.
To fix it just find the Scene iterators (three of them) in NxOgre_World.cpp. Around line: 310, 329 and at 421. You'll find a line that says "delete (*i);" add the following after that, do it for all three.
mScene.erase(i);
I'm not saying it'll fix your problem, but it's worth a shot.
M@gg!
29-08-2006 17:52:34
I'm not saying it'll fix your problem, but it's worth a shot.
Sadly it didn't hit the point. But thanks for the help.
M@gg!
29-08-2006 20:31:09
At the weekend I'll make another try. I want this problem to be fixed. It's making me nuts!
BlasterN
31-08-2006 01:00:16
mBdyBody->mNode->removeChild(mNodParticleSystem);
mNodParticleSystem->detachObject(mParticleSystem);
mSceneManager->destroyParticleSystem(mParticleSystem);
try using this instead.
mSceneManager->destroySceneNode(mNodParticleSystem->getName());
mSceneManager->destroyParticleSystem(mParticleSystem);
betajaen
04-09-2006 12:37:02
It may be related but I just fixed a bug that I don't know how got in, that crashed when the last scene was deleted.
No idea how it got into the code though.