From b514d806865585af8c2c26f204fb9b14057603c3 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 10 Sep 2007 19:23:00 +0000 Subject: [PATCH] LCL: fixed removing TCustomPage pfAdded when destroying handle git-svn-id: trunk@11991 - --- lcl/extctrls.pp | 1 + lcl/include/customnotebook.inc | 8 +++++++- lcl/include/custompage.inc | 6 ++++++ lcl/include/wincontrol.inc | 4 ++-- lcl/interfaces/gtk2/gtk2wsextctrls.pp | 3 ++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lcl/extctrls.pp b/lcl/extctrls.pp index f43738a4e5..673ec312c5 100644 --- a/lcl/extctrls.pp +++ b/lcl/extctrls.pp @@ -69,6 +69,7 @@ type function DialogChar(var Message: TLMKey): boolean; override; procedure DoHide; dynamic; procedure DoShow; dynamic; + procedure DestroyHandle; override; public constructor Create(TheOwner: TComponent); override; procedure AdjustClientRect(var ARect: TRect); override; diff --git a/lcl/include/customnotebook.inc b/lcl/include/customnotebook.inc index 2462ab1ff5..7c21f6cf25 100644 --- a/lcl/include/customnotebook.inc +++ b/lcl/include/customnotebook.inc @@ -18,7 +18,7 @@ ***************************************************************************** } -{ $DEFINE NOTEBOOK_DEBUG} +{off $DEFINE NOTEBOOK_DEBUG} {------------------------------------------------------------------------------ TNBPages Constructor @@ -544,12 +544,18 @@ procedure TCustomNoteBook.AddRemovePageHandle(APage: TCustomPage); begin if (not (csDestroying in APage.ComponentState)) and (APage.TabVisible or (csDesigning in ComponentState)) then begin + {$IFDEF NOTEBOOK_DEBUG} + DebugLn(['TCustomNoteBook.AddRemovePageHandle ADD ',DbgSName(APage),' pfAdded=',pfAdded in APage.FFlags]); + {$ENDIF} if (pfAdded in APage.FFlags) then exit; Include(APage.FFlags,pfAdding); TWSCustomNotebookClass(WidgetSetClass).AddPage(Self, APage, APage.VisibleIndex); APage.FFlags:=APage.FFlags+[pfAdded]-[pfAdding]; APage.ResizeDelayedAutoSizeChildren end else begin + {$IFDEF NOTEBOOK_DEBUG} + DebugLn(['TCustomNoteBook.AddRemovePageHandle REMOVE ',DbgSName(APage),' pfAdded=',pfAdded in APage.FFlags]); + {$ENDIF} if not (pfAdded in APage.FFlags) then exit; Exclude(APage.FFlags,pfAdded); TWSCustomNotebookClass(WidgetSetClass).RemovePage(Self, APage.VisibleIndex); diff --git a/lcl/include/custompage.inc b/lcl/include/custompage.inc index b19e73b5a6..666c05cee9 100644 --- a/lcl/include/custompage.inc +++ b/lcl/include/custompage.inc @@ -200,6 +200,12 @@ begin FOnShow(Self); end; +procedure TCustomPage.DestroyHandle; +begin + inherited DestroyHandle; + Exclude(FFlags,pfAdded); +end; + function TCustomPage.IsControlVisible: Boolean; begin if Parent is TCustomNotebook then diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index ebe6891e2d..6ebc3f9dfb 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -3402,8 +3402,8 @@ begin Include(FControlState, csDestroyingHandle); if FWinControls <> nil then begin for i:= 0 to FWinControls.Count - 1 do begin - //DebugLn(' i=',i); - //DebugLn(' ',TWinControl(FWinControls[i]).Name,':',TWinControl(FWinControls[i]).ClassName); + //DebugLn([' i=',i]); + //DebugLn([' ',TWinControl(FWinControls[i]).Name,':',TWinControl(FWinControls[i]).ClassName]); AWinControl:=TWinControl(FWinControls[i]); if AWinControl.HandleAllocated then AWinControl.DestroyHandle; diff --git a/lcl/interfaces/gtk2/gtk2wsextctrls.pp b/lcl/interfaces/gtk2/gtk2wsextctrls.pp index 7e141ff28b..f69f62a079 100644 --- a/lcl/interfaces/gtk2/gtk2wsextctrls.pp +++ b/lcl/interfaces/gtk2/gtk2wsextctrls.pp @@ -243,7 +243,8 @@ var begin if OldNoteBookButtonPress = nil then HookNoteBookClass; - P := PGtkNoteBook(inherited CreateHandle(AWinControl, AParams)); + //DebugLn(['TGtk2WSCustomNotebook.CreateHandle ',DbgSName(AWinControl)]); + P := PGtkNoteBook(TGtkWSCustomNotebook.CreateHandle(AWinControl, AParams)); Result := HWND(P); end;