In GMS2.x, closing UIFrame window with the code shown below will cause DM to crash (at pressing the close button.)
However, the same code works fine with GMS 1.x.
Is there a way to work around this problem in GMS 2.x?
class UIWindowCloseTest : UIFrame {
void CloseSelf( object self ) self.GetFrameWindow().WindowClose(0);
UIWindowCloseTest( object self ) {
TagGroup tgDialog = DLGCreateDialog( "window close test" );
tgDialog.DLGAddElement( DLGCreatePushButton( "Close", "CloseSelf" ));
self.super.init(tgDialog);
self.Display( "test" );
result( self.ScriptObjectGetID().Hex() + " constructed\n" );
};
~UIWindowCloseTest( object self ) \
result( self.ScriptObjectGetID().Hex() + " destructed\n\n" );
};
alloc(UIWindowCloseTest);
This is the extension of this questions for GMS 3.X:
In essense, the answer below is correct for GMS 3 as well, but only since its version 3.2 (Maybe GMS 3.1.2 as well).
Earlier versions of GMS 3 have a bug as KEVIVI pointed out in the comment to the answer.
However, there is a work-around solution to this, which is slightly elaborate:
So:
For GMS 3.2 and later: Use
self.close();
For GMS 3.0 and 3.1 (with the bug): Use the workaround.
For GMS 2.x: Use
self.close();
For GMS 1.x: Use
self.GetFrameWindow().WindowClose(0);
Yes, in GMS 2.x you have to use
self.close();
instead of
self.GetFrameWindow().WindowClose(0);