Hi
When I call GameMain::GetInstance()->GetIrrDevice()->drop();
as the last line of code in my program it crashes. Shouldn't irrlicht handle to deallocate everything? As it is right now I have no idea if I am doing something wrong or if it's an irrlicht bug.
Thanks
Joachim
Should device->drop() handle all deallocation?
-
- Posts: 6
- Joined: Thu May 20, 2004 9:40 pm
EDIT: Disconsider what I've written if you have succeeded in actually calling the device pointer elsewhere after its creation.
I had a similar problem last night; are you sure your device pointer is valid? If you've only initialized the device so far in your code the chances are it isn't. It turned out mine wasn't. Whenever I attempted to modify it (createDevice()), the result was not stored at the correct address, even though the right effects happened (the window got shows up). Any attempts to call a member function by this pointer though was futile and would only result in crashes because apparently I had made a local copy in main() of the actual pointer I intended to modify...
I had a similar problem last night; are you sure your device pointer is valid? If you've only initialized the device so far in your code the chances are it isn't. It turned out mine wasn't. Whenever I attempted to modify it (createDevice()), the result was not stored at the correct address, even though the right effects happened (the window got shows up). Any attempts to call a member function by this pointer though was futile and would only result in crashes because apparently I had made a local copy in main() of the actual pointer I intended to modify...
That is the correct procedure, so the most likely problem is the pointer is invalid somehow. Two of the most likely causes:
1.) The createDevice() may fail in which case the pointer will be null. If drop() is then called it will crash.
2.) If drop() is being called twice you'll get a double delete, which will then crash.
1.) The createDevice() may fail in which case the pointer will be null. If drop() is then called it will crash.
2.) If drop() is being called twice you'll get a double delete, which will then crash.
The best way to handle this, since you will want to assure that all memory assigned gets deallocated. What I tend to do is in mu shutdown code is call the following:
This way, I can make sure that if the IrrlichtDevice exists, it gets deleted. Otherwise, I don't worry.
Code: Select all
if(IDevice) IDevice->drop();
"Object-oriented programming is an exceptionally bad idea which could only have originated in California."
- E.W. Dijkstra
- E.W. Dijkstra