新增对单例类的内存释放

This commit is contained in:
csh 2024-07-09 13:32:16 +08:00
parent 5fe2911608
commit 615f4a5b39
2 changed files with 7 additions and 0 deletions

View File

@ -58,6 +58,7 @@ end;
function TSDocxToPdf.Destroy(); function TSDocxToPdf.Destroy();
begin begin
removeDir("", cache_path_); removeDir("", cache_path_);
class(TSPdfSingletonKit).Release(docx_components_);
end; end;
function TSDocxToPdf.SaveToFile(alias: string; file: string): integer; function TSDocxToPdf.SaveToFile(alias: string; file: string): integer;

View File

@ -1,6 +1,7 @@
type TSPdfSingletonKit = class type TSPdfSingletonKit = class
public public
function Create(); function Create();
class function Release(components: Components);
class function GetComponent(components: Components; type: string); class function GetComponent(components: Components; type: string);
public public
hash_: array of tslobj; hash_: array of tslobj;
@ -14,6 +15,11 @@ begin
hash_ := array(); hash_ := array();
end; end;
class function TSPdfSingletonKit.Release(components: Components);
begin
singleton_.hash_[components] := nil;
end;
class function TSPdfSingletonKit.GetComponent(components: Components; type: string); class function TSPdfSingletonKit.GetComponent(components: Components; type: string);
begin begin
if not ifObj(singleton_) then singleton_ := new TSPdfSingletonKit(); if not ifObj(singleton_) then singleton_ := new TSPdfSingletonKit();