[BUG?]GUI disposing crash
by Cosmic Logic · in Torque X 2D · 08/02/2010 (5:15 am) · 2 replies
Hey,
This instance was found with a GUIBitmap. I'm not sure if the problem would exist with other GUIControls or not. It only happens with my parent control. The rest of the controls in the menu are children of my top GUIBitmap and therefore not considered objects in the TorqueSceneData.
My game menu GUI is made up of XML files. I switch between screens using the sceneloader loading and unloadlastscene.
I figure I would give you guys a heads up but when you unload a .xml file that has GUIBitmaps in it, the Dispose() method is called twice due to the scene unloading process.
I fixed this simply with a
in the GUIBitmap's Dispose method.
What happens is that the GUIBitmap is unregistered(which calls it's Dispose) in the TorqueSceneData._UnloadObjects(...) method then, it calls the dispose again.
Not sure if I explained this all that well, but I hope this helps.
This instance was found with a GUIBitmap. I'm not sure if the problem would exist with other GUIControls or not. It only happens with my parent control. The rest of the controls in the menu are children of my top GUIBitmap and therefore not considered objects in the TorqueSceneData.
My game menu GUI is made up of XML files. I switch between screens using the sceneloader loading and unloadlastscene.
I figure I would give you guys a heads up but when you unload a .xml file that has GUIBitmaps in it, the Dispose() method is called twice due to the scene unloading process.
I fixed this simply with a
if(!_IsDisposed) {
_IsDisposed = true;
_material = null;
base.Dispose();
}in the GUIBitmap's Dispose method.
What happens is that the GUIBitmap is unregistered(which calls it's Dispose) in the TorqueSceneData._UnloadObjects(...) method then, it calls the dispose again.
Not sure if I explained this all that well, but I hope this helps.
#2
Here's the first time it's called:
And here's the second time, where it crashes because it was already disposed:
If you want to replicate it, make an xml file with this:
And put this in your BeginRun to test it:
SceneLoader.Load(@"dataGUIGUITesty.xml");
SceneLoader.UnloadLastScene();
It should crash at _objects.Clear()
08/03/2010 (6:12 pm)
Sure.Here's the first time it's called:
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.GUI.GUIBitmap.Dispose() Line 340 C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.Core.TorqueObjectDatabase.Unregister(GarageGames.Torque.Core.TorqueObject obj = {GarageGames.Torque.GUI.GUIBitmap}, bool dispose = true) Line 501 + 0x9 bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.Core.TorqueObjectDatabase.Unregister(GarageGames.Torque.Core.TorqueObject obj = {GarageGames.Torque.GUI.GUIBitmap}) Line 425 + 0xd bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.Core.TorqueFolder.OnUnregister() Line 1550 + 0x28 bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.Core.TorqueObjectDatabase.Unregister(GarageGames.Torque.Core.TorqueObject obj = {GarageGames.Torque.Core.TorqueFolder}, bool dispose = true) Line 458 + 0x8 bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.Core.TorqueObjectDatabase.Unregister(GarageGames.Torque.Core.TorqueObject obj = {GarageGames.Torque.Core.TorqueFolder}) Line 425 + 0xd bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.Core.Xml.TorqueSceneData.Unload() Line 364 + 0x18 bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.GameUtil.SceneLoader.Unload(GarageGames.Torque.Core.Xml.TorqueSceneData scene = {GarageGames.Torque.Core.Xml.TorqueSceneData}) Line 166 + 0xa bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.GameUtil.SceneLoader.UnloadLastScene() Line 201 + 0xe bytes C#And here's the second time, where it crashes because it was already disposed:
> GarageGames.TorqueX.Framework.dll!GarageGames.Torque.GUI.GUIBitmap.Dispose() Line 340 C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.Core.Xml.TorqueSceneData._UnloadObjects(System.Collections.Generic.List<object> list = Count = 2) Line 569 + 0x15 bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.Core.Xml.TorqueSceneData.Unload() Line 369 + 0xe bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.GameUtil.SceneLoader.Unload(GarageGames.Torque.Core.Xml.TorqueSceneData scene = {GarageGames.Torque.Core.Xml.TorqueSceneData}) Line 166 + 0xa bytes C#
GarageGames.TorqueX.Framework.dll!GarageGames.Torque.GameUtil.SceneLoader.UnloadLastScene() Line 201 + 0xe bytes C#If you want to replicate it, make an xml file with this:
<?xml version="1.0" encoding="utf-8" ?>
<TorqueSceneData>
<Version>1.0</Version>
<SceneData>
<GUIBitmapStyle name="basicStyle">
<SizeToBitmap>false</SizeToBitmap>
</GUIBitmapStyle>
<GUIBitmap name="Screen">
<Style nameRef="basicStyle"/>
<Bitmap>dataimagesGUImainMenuBackground</Bitmap>
</GUIBitmap>
</SceneData>
</TorqueSceneData>And put this in your BeginRun to test it:
SceneLoader.Load(@"dataGUIGUITesty.xml");
SceneLoader.UnloadLastScene();
It should crash at _objects.Clear()
Associate Giuseppe De Francesco
DFT Games Ltd
looking at your issue I gather that somewhere in the code there is an explicit call to the Dispose method. I can't find this in the engine: do you mind to post your stack trace?
Thanks,
Pino