From 8d23789d877af358edb1aeca75e42e6953f0179f Mon Sep 17 00:00:00 2001 From: graemeg Date: Mon, 21 Jan 2008 11:18:44 +0000 Subject: * Fixed some memory leaks in TfpgComboBox. * Fixed the destruction order of TfpgComboBox. * Introduced DoRemoveWindowLookup() in gfxbase.pas so that we can offload some of the responsibility from DoReleaseWindowHandle() * Add two new debug methods to help debug fpGUI and fpGUI based applications. They are PrintCallTrace() and PrintCallTraceDbgln(). * Fixed 'Index out of bounds' error when quiting your application. * I included lots of debug output in this revision, so I can test under Windows. As soon as I confirmed everything works, I'll remove the debug output again. --- src/corelib/x11/gfx_x11.pas | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'src/corelib/x11') diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index a7b37812..a8cbe44a 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -134,6 +134,7 @@ type FModalForWin: TfpgWindowImpl; procedure DoAllocateWindowHandle(AParent: TfpgWindowBase); override; procedure DoReleaseWindowHandle; override; + procedure DoRemoveWindowLookup; override; procedure DoSetWindowVisible(const AValue: Boolean); override; function HandleIsValid: boolean; override; procedure DoSetWindowTitle(const ATitle: string); override; @@ -734,8 +735,10 @@ begin Popup := PopupListFirst; -// WriteLn('Event ',GetXEventName(ev._type),': ', ev._type,' window: ', ev.xany.window); + {$IFDEF DEBUG} + WriteLn('Event ',GetXEventName(ev._type),': ', ev._type,' window: ', ev.xany.window); // PrintKeyEvent(ev); { debug purposes only } + {$ENDIF} case ev._type of X.KeyPress, @@ -1182,17 +1185,30 @@ begin end; procedure TfpgWindowImpl.DoReleaseWindowHandle; +var + lCallTrace: IInterface; begin - if FWinHandle <= 0 then - Exit; - - XDestroyWindow(xapplication.Display, FWinHandle); - // RemoveWindowLookup is now deferred to DestroyNotify event. -// RemoveWindowLookup(self); + lCallTrace := PrintCallTrace(Classname, 'DoReleaseWindowHandle: ' + Name); + if HandleIsValid then + begin + PrintCallTraceDbgLn('XDestroyWindow'); + XDestroyWindow(xapplication.Display, FWinHandle); + end + else + begin + PrintCallTraceDbgLn(' RemoveWindowLookup'); + RemoveWindowLookup(self); + end; FWinHandle := 0; end; +procedure TfpgWindowImpl.DoRemoveWindowLookup; +begin + PrintCallTraceDbgLn('RemoveWindowLookup ' + Name + ' [' + Classname + ']'); + RemoveWindowLookup(self); +end; + procedure TfpgWindowImpl.DoSetWindowVisible(const AValue: Boolean); begin if AValue then -- cgit v1.2.3-70-g09d2