SynEdit: Wrapped-view, fix leaks. Remove event-handler and view in Destroy

(cherry picked from commit e331c9fb35)
This commit is contained in:
Martin 2025-01-24 20:51:09 +01:00
parent 2b4decdf35
commit 5ae99331c1
2 changed files with 14 additions and 0 deletions

View File

@ -2682,6 +2682,7 @@ var
i: integer; i: integer;
p: TList; p: TList;
begin begin
Destroying;
{$IFDEF SynCheckPaintLock} {$IFDEF SynCheckPaintLock}
if (FPaintLock > 0) then begin if (FPaintLock > 0) then begin
debugln(['TCustomSynEdit.Destroy: Paintlock=', FPaintLock, ' FInvalidateRect=', dbgs(FInvalidateRect)]); debugln(['TCustomSynEdit.Destroy: Paintlock=', FPaintLock, ' FInvalidateRect=', dbgs(FInvalidateRect)]);

View File

@ -221,6 +221,7 @@ public
function CalculateWrapForLine(ALineIdx: IntIdx; AMaxWidth: integer): Integer; inline; function CalculateWrapForLine(ALineIdx: IntIdx; AMaxWidth: integer): Integer; inline;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure WrapAll; experimental; procedure WrapAll; experimental;
procedure ValidateAll; experimental; procedure ValidateAll; experimental;
@ -1811,6 +1812,18 @@ begin
WrapAll; WrapAll;
end; end;
destructor TLazSynEditLineWrapPlugin.Destroy;
begin
if Editor <> nil then begin
TSynEdit(Editor).UnRegisterStatusChangedHandler(@DoWidthChanged);
if (FLineMapView <> nil) and not (csDestroying in Editor.Componentstate) then begin
TSynEdit(Editor).TextViewsManager.RemoveSynTextView(FLineMapView, True);
TSynEdit(Editor).Invalidate;
end;
end;
inherited Destroy;
end;
procedure TLazSynEditLineWrapPlugin.WrapAll; procedure TLazSynEditLineWrapPlugin.WrapAll;
var var
c: Integer; c: Integer;