LCL: fixed removing TCustomPage pfAdded when destroying handle

git-svn-id: trunk@11991 -
This commit is contained in:
mattias 2007-09-10 19:23:00 +00:00
parent 4647c02ff0
commit b514d80686
5 changed files with 18 additions and 4 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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;