Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pyscripter committed Jan 16, 2024
1 parent 36da003 commit 13bbef7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Source/SynDWrite.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,8 @@ TSynDWrite = class
class function DottedStrokeStyle: ID2D1StrokeStyle; static;
class function GradientGutterBrush(StartColor, EndColor: TColor): ID2D1LinearGradientBrush;
class procedure ResetRenderTarget; static;
// if SynEdit inside a DLL call Finalize before unloading the DLL (https://github.com/TurboPack/SynEdit/issues/249)
class procedure Finalize;
end;

TSynTextFormat = record
Expand Down Expand Up @@ -1791,6 +1793,17 @@ class function TSynDWrite.DWriteFactory: IDWriteFactory;
Result := SingletonDWriteFactory;
end;

class procedure TSynDWrite.Finalize;
begin
FreeAndNil(TSynDWrite.FSolidBrushes);
TSynDWrite.SingletonDottedStrokeStyle := nil;
TSynDWrite.SingletonRenderTarget := nil;
TSynDWrite.SingletonGDIInterop := nil;
TSynDWrite.SingletonImagingFactory := nil;
TSynDWrite.SingletonPrintDocumentPackageTargetFactory := nil;
TSynDWrite.SingletonD2DFactory := nil;
end;

class function TSynDWrite.GDIInterop: IDWriteGdiInterop;
var
LocalGDIInterop: IDWriteGdiInterop;
Expand Down Expand Up @@ -2209,5 +2222,5 @@ initialization
clNoneF := D2D1ColorF(0, 0, 0, 0);
finalization
// Delphi 10.1 does not support class destructors
TSynDWrite.FSolidBrushes.Free;
TSynDWrite.Finalize;
end.

0 comments on commit 13bbef7

Please sign in to comment.