Crash when ISceneNode deleted by user

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

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 :D
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. :D
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

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
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

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).
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

:!: Ok, forget everything from before. Simple things are still the best:

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);
		    }
		}
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.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

but getDebugName only returns the name if Irrlicht was compiled in debug mode !!! ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply