From e1c32b70e504cd683dda33ab379b6148e5e961ca Mon Sep 17 00:00:00 2001 From: Mark van Renswoude Date: Wed, 2 Jun 2010 10:15:24 +0000 Subject: [PATCH] Fixed: free notification wasn't handled for a linked Action --- Source/X2CLMenuBar.pas | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Source/X2CLMenuBar.pas b/Source/X2CLMenuBar.pas index 44300df..ed55801 100644 --- a/Source/X2CLMenuBar.pas +++ b/Source/X2CLMenuBar.pas @@ -327,6 +327,7 @@ type procedure DoActionChange(Sender: TObject); protected procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); virtual; + procedure ActionNotification(Sender: TObject; AComponent: TComponent; Operation: TOperation); virtual; function IsCaptionStored: Boolean; virtual; function GetMenuBar: TX2CustomMenuBar; virtual; @@ -1198,6 +1199,17 @@ begin end; +procedure TX2CustomMenuBarItem.ActionNotification(Sender: TObject; AComponent: TComponent; Operation: TOperation); +begin + if (AComponent = FAction) and (Operation = opRemove) then + begin + { Don't free FNotification here, we're in it's event handler } + FAction := nil; + FreeAndNil(FActionLink); + end; +end; + + function TX2CustomMenuBarItem.IsCaptionStored: Boolean; begin Result := (Length(Caption) > 0); @@ -1252,7 +1264,10 @@ begin FActionLink.Action := Value; if not Assigned(FNotification) then + begin FNotification := TX2ComponentNotification.Create(nil); + FNotification.OnNotification := ActionNotification; + end; ActionChange(Value, csLoading in Value.ComponentState); FAction.FreeNotification(FNotification);