From fe73e95e263dbffa96386ab1aa2b3cd7a78e66dc Mon Sep 17 00:00:00 2001 From: Felipe Menteiro de Carvalho Date: Thu, 17 May 2007 05:55:12 +0000 Subject: Improved form freeing code and general handling of GFApplication.Forms --- gfx/gdi/gfx_gdi.pas | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'gfx/gdi/gfx_gdi.pas') diff --git a/gfx/gdi/gfx_gdi.pas b/gfx/gdi/gfx_gdi.pas index ddbc1d1b..7964f222 100644 --- a/gfx/gdi/gfx_gdi.pas +++ b/gfx/gdi/gfx_gdi.pas @@ -1020,8 +1020,7 @@ begin Windows.ReleaseDC(0, TempDC); end; -function TGDIScreen.CreateMonoBitmapCanvas(AWidth, AHeight: Integer - ): TFCustomCanvas; +function TGDIScreen.CreateMonoBitmapCanvas(AWidth, AHeight: Integer): TFCustomCanvas; var TempDC: HDC; begin @@ -1040,13 +1039,10 @@ begin end; +{ Itīs not the job of the Application object to clean up undestroyed forms + This can generate crashes } destructor TGDIApplication.Destroy; -var - i: Integer; begin - for i := 0 to Forms.Count - 1 do - TGDIWindow(Forms[i]).Free; - inherited Destroy; end; @@ -1156,11 +1152,15 @@ begin Event.EventType := etShow; Window.ProcessEvent(Event); + + GFApplication.AddWindow(Window); end else begin Event.EventType := etHide; Window.ProcessEvent(Event); + + GFApplication.RemoveWindow(Window); end; end; WM_Move: @@ -1406,10 +1406,10 @@ begin Windows.DestroyWindow(OldHandle); end; - GFApplication.Forms.Remove(Self); + GFApplication.RemoveWindow(Self); // Are we the last window for our owning application? - if GFApplication.Forms.Count = 0 then + if (GFApplication.QuitWhenLastWindowCloses and (GFApplication.Forms.Count = 0)) then Windows.PostQuitMessage(0); inherited Destroy; -- cgit v1.2.3-70-g09d2