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

@@ -15,7 +15,7 @@ unit spkt_Buttons;
interface
uses
uses LazLoggerBase,
Graphics, Classes, Types, Controls, Menus, ActnList, Math,
Dialogs, ImgList, Forms,
SpkGUITools, SpkGraphTools, SpkMath,
@@ -127,6 +127,7 @@ type
function GetRootComponent: TComponent;
function IsRightToLeft: Boolean;
procedure Notify(Item: TComponent; Operation: TOperation); override;
property ActionLink: TSpkButtonActionLink read FActionLink;
property Checked: Boolean read GetChecked write SetChecked default false;
@@ -528,6 +529,15 @@ begin
Result := (GetRootComponent as TControl).IsRightToLeft;
end;
procedure TSpkBaseButton.Notify(Item: TComponent; Operation: TOperation);
begin
if (Operation = opRemove) and (Item = FDropDownMenu) then
begin
DropDownMenu := nil;
DebugLn('[TSpkBaseButton.Notify] Button "' + caption + '" removed ' + Item.ClassName);
end;
end;
procedure TSpkBaseButton.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin