Thanks for the code but actually I had another idea how to solve this: not use Irrlicht at all (that should work for sure).
Just kindding
I see threre is no way to solve this without making even more trouble.
My own idea was to make an intelligent reference class which knows what to do by default but I guess that will take some time.
Crash when ISceneNode deleted by user
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
I'm actually coming round to thinking that perhaps we should do something about it. It's a bit nasty to have reference counted objects that don't actually know whether they can delete themselves. We've currently got a situation where the owner implicitly just doesn't drop() some objects, which makes me a bit uncomfortable.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
I think your 2nd suggestion about creating a reference counted object with a default value of 0 would be a nice pointe to start. As far I know all objects in Irrlicht which might need a reference count are created with createSomething, addSomething or getSomething. So it should not be a big deal to grab() them there. All other objects which are created by the user with new would have to be grabbed explicitly.
Another possible solution for this, that is maybe more safe, could be an IReferenceCounted class which asks how the object has been created by a bool parameter in the constructor (this would have to be added to all derived classes constructors).
Another possible solution for this, that is maybe more safe, could be an IReferenceCounted class which asks how the object has been created by a bool parameter in the constructor (this would have to be added to all derived classes constructors).
Ok, forget everything from before. Simple things are still the best:
This way it should not matter how the object has been created whether on the heap or the stack. Removing it with a reference count of 1 doesn't harm anyone. But if it's used by more than one it will warn the user about unresolved references and help to find the problem.
Any objections?
I also thought about an extra virtual function for this class which could provide more detailed information such as name, id or type of the derived class but I guess getDebugName is something similar.
Code: Select all
//! Destructor.
virtual ~IReferenceCounted()
{
// reference counted object destroyed improperly
if( ReferenceCounter > 1 )
{
printf("warning: incorrect destruction of IReferenceCounted object, used by %i\n",ReferenceCounter);
printf("--object name: %s\n",DebugName);
}
}
Any objections?
I also thought about an extra virtual function for this class which could provide more detailed information such as name, id or type of the derived class but I guess getDebugName is something similar.
but getDebugName only returns the name if Irrlicht was compiled in debug mode !!!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java