You've already forked lazarus-ccr
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:
@ -48,6 +48,8 @@ type TSpkBaseButton = class;
|
|||||||
function IsVisibleLinked: Boolean; override;
|
function IsVisibleLinked: Boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TSpkBaseButton }
|
||||||
|
|
||||||
TSpkBaseButton = class abstract(TSpkBaseItem)
|
TSpkBaseButton = class abstract(TSpkBaseItem)
|
||||||
private
|
private
|
||||||
FMouseHoverElement : TSpkMouseButtonElement;
|
FMouseHoverElement : TSpkMouseButtonElement;
|
||||||
@ -96,6 +98,7 @@ type TSpkBaseButton = class;
|
|||||||
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner : TComponent); override;
|
constructor Create(AOwner : TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
|
||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
|
||||||
@ -295,6 +298,12 @@ begin
|
|||||||
FMouseActiveElement:=beNone;
|
FMouseActiveElement:=beNone;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
destructor TSpkBaseButton.Destroy;
|
||||||
|
begin
|
||||||
|
FreeAndNil(FActionLink);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSpkBaseButton.Click;
|
procedure TSpkBaseButton.Click;
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnClick) then
|
if Assigned(FOnClick) then
|
||||||
@ -648,14 +657,14 @@ end;
|
|||||||
procedure TSpkBaseButton.SetAction(const Value: TBasicAction);
|
procedure TSpkBaseButton.SetAction(const Value: TBasicAction);
|
||||||
begin
|
begin
|
||||||
if Value = nil then
|
if Value = nil then
|
||||||
begin
|
begin
|
||||||
FActionLink.Free;
|
FActionLink.Free;
|
||||||
FActionLink := nil;
|
FActionLink := nil;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if FActionLink = nil then
|
if FActionLink = nil then
|
||||||
FActionLink := TSpkButtonActionLink.Create(self);
|
FActionLink := TSpkButtonActionLink.Create(self);
|
||||||
FActionLink.Action := Value;
|
FActionLink.Action := Value;
|
||||||
FActionLink.OnChange := DoActionChange;
|
FActionLink.OnChange := DoActionChange;
|
||||||
ActionChange(Value, csLoading in Value.ComponentState);
|
ActionChange(Value, csLoading in Value.ComponentState);
|
||||||
|
Reference in New Issue
Block a user