[Git] Bug in Scene destructor

Druha

25-10-2009 11:16:14

Hi, betajaen!
I followed your suggestion to recreate Scene when I change map.
But after I destroy a scene in the next frame I get an error somwhere inside TimeController. I've looked through code and found a bug.
In Scene constructror:

// .. some code ..
TimeController::getSingleton()->mListeners[mProcessingPriority].insert(this);
TimeController::getSingleton()->mListeners[mFetchingPriority].insert(this);
// .. some other code ..

But in destructor only:

/// TimeController::getSingleton()->removeListener(this); < -- yeah it is commented here!
if (mSDK && mScene)
{
mActors.destroyAll();
mSceneGeometries.destroyAll();
mKinematicActors.destroyAll();
mKinematicControllers.destroyAll();
mVolumes.destroyAll();
mMaterials.destroyAll();
mCloths.destroyAll();
mSoftBodies.destroyAll();
NxOgre_Delete(mSceneTimer);
mSDK->releaseScene(*mScene);
NxOgre_Delete(mPhysXCallback);
}

I've looked at the last git commit - that comment still exists there.
I've replaced that commented line with:

TimeController::getSingleton()->mListeners[mProcessingPriority].remove(this);
TimeController::getSingleton()->mListeners[mFetchingPriority].remove(this);

Everything works fine now. Hope it'll be helpfull for someone...

Commit, I am using - http://github.com/betajaen/nxogre/commi ... 50b4a4afb3

betajaen

25-10-2009 11:31:14

It was in Detritus as well;

http://github.com/betajaen/nxogre/commi ... 3914dc024a
http://github.com/betajaen/nxogre/commi ... c4cb16e8fe

I need to convert the TimeListener arrays in to STL ones in Detritus anyway. So, it will give me an excuse to handle classes that use the time listener code more than once.