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:
wp_xxyyzz 2014-10-13 18:46:12 +00:00
parent ce54f48dc3
commit ff5dba6c66

View File

@ -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);