mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 16:19:36 +02:00
cocoa: fix controls leaking spinedit
git-svn-id: trunk@59235 -
This commit is contained in:
parent
465a09fb02
commit
5738bbf955
@ -325,7 +325,8 @@ type
|
||||
procedure dealloc; override;
|
||||
function updateStepper: boolean; message 'updateStepper';
|
||||
procedure UpdateControl(min, max, inc, avalue: double; ADecimalPlaces: Integer); message 'UpdateControl:::::';
|
||||
procedure CreateSubcontrols(const AParams: TCreateParams); message 'CreateSubControls:';
|
||||
procedure lclCreateSubcontrols(const AParams: TCreateParams); message 'lclCreateSubControls:';
|
||||
procedure lclReleaseSubcontrols; message 'lclReleaseSubcontrols';
|
||||
procedure PositionSubcontrols(const ALeft, ATop, AWidth, AHeight: Integer); message 'PositionSubcontrols:ATop:AWidth:AHeight:';
|
||||
procedure StepperChanged(sender: NSObject); message 'StepperChanged:';
|
||||
procedure textDidEndEditing(notification: NSNotification); message 'textDidEndEditing:'; override;
|
||||
@ -1524,11 +1525,7 @@ end;
|
||||
|
||||
procedure TCocoaSpinEdit.dealloc;
|
||||
begin
|
||||
if Stepper <> nil then
|
||||
Stepper.release;
|
||||
if NumberFormatter <> nil then
|
||||
NumberFormatter.release;
|
||||
|
||||
lclReleaseSubControls;
|
||||
inherited dealloc;
|
||||
end;
|
||||
|
||||
@ -1574,7 +1571,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCocoaSpinEdit.CreateSubcontrols(const AParams: TCreateParams);
|
||||
procedure TCocoaSpinEdit.lclCreateSubcontrols(const AParams: TCreateParams);
|
||||
var
|
||||
lParams: TCreateParams;
|
||||
begin
|
||||
@ -1621,6 +1618,21 @@ begin
|
||||
setFormatter(NumberFormatter);}
|
||||
end;
|
||||
|
||||
procedure TCocoaSpinEdit.lclReleaseSubcontrols;
|
||||
begin
|
||||
if Assigned(Stepper) then
|
||||
begin
|
||||
Stepper.removeFromSuperview;
|
||||
Stepper.release;
|
||||
Stepper := nil;
|
||||
end;
|
||||
if Assigned(NumberFormatter) then
|
||||
begin
|
||||
NumberFormatter.release;
|
||||
NumberFormatter := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCocoaSpinEdit.PositionSubcontrols(const ALeft, ATop, AWidth, AHeight: Integer);
|
||||
begin
|
||||
lclSetFrame(Types.Bounds(ALeft, ATop, AWidth, AHeight));
|
||||
|
@ -35,6 +35,7 @@ type
|
||||
TCocoaWSCustomFloatSpinEdit = class(TWSCustomFloatSpinEdit)
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class procedure DestroyHandle(const AWinControl: TWinControl); override;
|
||||
class function GetValue(const ACustomFloatSpinEdit: TCustomFloatSpinEdit): Double; override;
|
||||
class procedure UpdateControl(const ACustomFloatSpinEdit: TCustomFloatSpinEdit); override;
|
||||
class procedure SetBounds(const AWinControl: TWinControl; const ALeft, ATop, AWidth, AHeight: Integer); override;
|
||||
@ -66,10 +67,17 @@ begin
|
||||
Result := TLCLIntfHandle(lSpin);
|
||||
if Result = 0 then Exit;
|
||||
lSpin.decimalPlaces := -1;
|
||||
lSpin.CreateSubcontrols(AParams);
|
||||
lSpin.lclCreateSubcontrols(AParams);
|
||||
lSpin.callback := TLCLCommonCallback.Create(lSpin, AWinControl);
|
||||
end;
|
||||
|
||||
class procedure TCocoaWSCustomFloatSpinEdit.DestroyHandle(const AWinControl: TWinControl);
|
||||
begin
|
||||
if not AWinControl.HandleAllocated then Exit;
|
||||
TCocoaSpinEdit(AWinControl.Handle).lclReleaseSubcontrols;
|
||||
TCocoaWSWinControl.DestroyHandle(AWinControl);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCocoaWSCustomFloatSpinEdit.GetValue
|
||||
Params: ACustomFloatSpinEdit - LCL custom float spin edit
|
||||
|
Loading…
Reference in New Issue
Block a user