spktoolbar: Fix memory leak when using actions on buttons in SpkToolbar (issue 0025732). Patch by Jorge Turiel.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3649 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
ce54f48dc3
commit
ff5dba6c66
@ -48,6 +48,8 @@ type TSpkBaseButton = class;
|
||||
function IsVisibleLinked: Boolean; override;
|
||||
end;
|
||||
|
||||
{ TSpkBaseButton }
|
||||
|
||||
TSpkBaseButton = class abstract(TSpkBaseItem)
|
||||
private
|
||||
FMouseHoverElement : TSpkMouseButtonElement;
|
||||
@ -96,6 +98,7 @@ type TSpkBaseButton = class;
|
||||
|
||||
public
|
||||
constructor Create(AOwner : TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
procedure MouseLeave; override;
|
||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||
@ -295,6 +298,12 @@ begin
|
||||
FMouseActiveElement:=beNone;
|
||||
end;
|
||||
|
||||
destructor TSpkBaseButton.Destroy;
|
||||
begin
|
||||
FreeAndNil(FActionLink);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TSpkBaseButton.Click;
|
||||
begin
|
||||
if Assigned(FOnClick) then
|
||||
@ -648,14 +657,14 @@ end;
|
||||
procedure TSpkBaseButton.SetAction(const Value: TBasicAction);
|
||||
begin
|
||||
if Value = nil then
|
||||
begin
|
||||
FActionLink.Free;
|
||||
FActionLink := nil;
|
||||
end
|
||||
begin
|
||||
FActionLink.Free;
|
||||
FActionLink := nil;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if FActionLink = nil then
|
||||
FActionLink := TSpkButtonActionLink.Create(self);
|
||||
begin
|
||||
if FActionLink = nil then
|
||||
FActionLink := TSpkButtonActionLink.Create(self);
|
||||
FActionLink.Action := Value;
|
||||
FActionLink.OnChange := DoActionChange;
|
||||
ActionChange(Value, csLoading in Value.ComponentState);
|
||||
|
Loading…
Reference in New Issue
Block a user