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;
p: TList;
begin
Destroying;
{$IFDEF SynCheckPaintLock}
if (FPaintLock > 0) then begin
debugln(['TCustomSynEdit.Destroy: Paintlock=', FPaintLock, ' FInvalidateRect=', dbgs(FInvalidateRect)]);

View File

@ -221,6 +221,7 @@ public
function CalculateWrapForLine(ALineIdx: IntIdx; AMaxWidth: integer): Integer; inline;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure WrapAll; experimental;
procedure ValidateAll; experimental;
@ -1811,6 +1812,18 @@ begin
WrapAll;
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;
var
c: Integer;