SpkToolbar: Fix crash when a popupmenu used by a button is destroyed.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8962 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-10-13 20:53:27 +00:00
parent a36b768a64
commit 6be867b8cd
7 changed files with 108 additions and 48 deletions

View File

@ -20,7 +20,7 @@ unit spkt_Tab;
interface
uses
uses LazLoggerBase,
Graphics, Controls, Classes, SysUtils, Math,
SpkMath,
spkt_Appearance, spkt_Const, spkt_Dispatch, spkt_Exceptions,
@ -686,11 +686,17 @@ begin
end;
procedure TSpkTabs.Notify(Item: TComponent; Operation: TOperation);
var
i: Integer;
tab: TSpkTab;
begin
inherited Notify(Item, Operation);
DebugLn('[TSpkTabs.Notify] Removing ' + Item.ClassName);
case Operation of
opInsert:
if Item is TSpkTab then
begin
// Setting the dispatcher to nil will cause that during the
// ownership assignment, the Notify method will not be called
@ -705,17 +711,23 @@ begin
TSpkTab(Item).ToolbarDispatch := self.FToolbarDispatch;
end;
opRemove:
if not(csDestroying in Item.ComponentState) then
if (Item is TSpkTab) then
begin
TSpkTab(Item).ToolbarDispatch := nil;
TSpkTab(Item).Appearance := nil;
TSpkTab(Item).Images := nil;
TSpkTab(Item).DisabledImages := nil;
TSpkTab(Item).LargeImages := nil;
TSpkTab(Item).DisabledLargeImages := nil;
// TSpkTab(Item).ImagesWidth := 0;
// TSpkTab(Item).LargeImagesWidth := 0;
end;
if not(csDestroying in Item.ComponentState) then
begin
TSpkTab(Item).ToolbarDispatch := nil;
TSpkTab(Item).Appearance := nil;
TSpkTab(Item).Images := nil;
TSpkTab(Item).DisabledImages := nil;
TSpkTab(Item).LargeImages := nil;
TSpkTab(Item).DisabledLargeImages := nil;
end;
end else
for i := 0 to Count-1 do
begin
tab := Items[i];
tab.Panes.Notify(Item, Operation);
end;
end;
end;