Fixed: free notification wasn't handled for a linked Action
This commit is contained in:
parent
6322d27e0c
commit
e1c32b70e5
@ -327,6 +327,7 @@ type
|
|||||||
procedure DoActionChange(Sender: TObject);
|
procedure DoActionChange(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); virtual;
|
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); virtual;
|
||||||
|
procedure ActionNotification(Sender: TObject; AComponent: TComponent; Operation: TOperation); virtual;
|
||||||
|
|
||||||
function IsCaptionStored: Boolean; virtual;
|
function IsCaptionStored: Boolean; virtual;
|
||||||
function GetMenuBar: TX2CustomMenuBar; virtual;
|
function GetMenuBar: TX2CustomMenuBar; virtual;
|
||||||
@ -1198,6 +1199,17 @@ begin
|
|||||||
end;
|
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;
|
function TX2CustomMenuBarItem.IsCaptionStored: Boolean;
|
||||||
begin
|
begin
|
||||||
Result := (Length(Caption) > 0);
|
Result := (Length(Caption) > 0);
|
||||||
@ -1252,7 +1264,10 @@ begin
|
|||||||
FActionLink.Action := Value;
|
FActionLink.Action := Value;
|
||||||
|
|
||||||
if not Assigned(FNotification) then
|
if not Assigned(FNotification) then
|
||||||
|
begin
|
||||||
FNotification := TX2ComponentNotification.Create(nil);
|
FNotification := TX2ComponentNotification.Create(nil);
|
||||||
|
FNotification.OnNotification := ActionNotification;
|
||||||
|
end;
|
||||||
|
|
||||||
ActionChange(Value, csLoading in Value.ComponentState);
|
ActionChange(Value, csLoading in Value.ComponentState);
|
||||||
FAction.FreeNotification(FNotification);
|
FAction.FreeNotification(FNotification);
|
||||||
|
Loading…
Reference in New Issue
Block a user