From 47bacafa821d70c4180702e4b77c9c70b3e43180 Mon Sep 17 00:00:00 2001 From: RyanTMontoya Date: Fri, 29 Mar 2024 09:23:15 -0700 Subject: [PATCH 1/3] Removed ifdef DisposeOf and added default Result for createinstance, both raise warnings in Delphi 12. The former's function is now depricated and the latter case was likely masked in previous compiler versions. --- Quick.RTTI.Utils.pas | 1 + Quick.Threads.pas | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Quick.RTTI.Utils.pas b/Quick.RTTI.Utils.pas index 1541554..b910557 100644 --- a/Quick.RTTI.Utils.pas +++ b/Quick.RTTI.Utils.pas @@ -88,6 +88,7 @@ class function TRTTI.CreateInstance(const Args: array of TValue): T; rmethod: TRttiMethod; rinstype: TRttiInstanceType; begin + Result := CreateInstance([]); rtype := fCtx.GetType(TypeInfo(T)); for rmethod in rtype.GetMethods do begin diff --git a/Quick.Threads.pas b/Quick.Threads.pas index b5387ab..2c24992 100644 --- a/Quick.Threads.pas +++ b/Quick.Threads.pas @@ -685,7 +685,7 @@ procedure TThreadedQueueCS.Clear; try for obj in FQueue do begin - if TypeInfo(T) = TypeInfo(TObject) then PObject(@obj){$IFNDEF FPC}.DisposeOf;{$ELSE}.Free;{$ENDIF} + if TypeInfo(T) = TypeInfo(TObject) then PObject(@obj).Free; end; SetLength(FQueue,0); From 6adee9c8eac313a628ff5498f56bf834fb01341f Mon Sep 17 00:00:00 2001 From: RyanTMontoya Date: Fri, 29 Mar 2024 10:36:52 -0700 Subject: [PATCH 2/3] better default value for result, removed mistaken understanding of CreateInstance --- Quick.RTTI.Utils.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quick.RTTI.Utils.pas b/Quick.RTTI.Utils.pas index b910557..27c2381 100644 --- a/Quick.RTTI.Utils.pas +++ b/Quick.RTTI.Utils.pas @@ -88,7 +88,7 @@ class function TRTTI.CreateInstance(const Args: array of TValue): T; rmethod: TRttiMethod; rinstype: TRttiInstanceType; begin - Result := CreateInstance([]); + Result := Default(T); rtype := fCtx.GetType(TypeInfo(T)); for rmethod in rtype.GetMethods do begin From 787bcbdcee8deabaad28f9dfcc4e2ec061f6c42f Mon Sep 17 00:00:00 2001 From: RyanTMontoya Date: Fri, 29 Mar 2024 12:49:53 -0700 Subject: [PATCH 3/3] Adjusted compiler condition for 12 and up to be compatible with old conditions --- Quick.Threads.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Quick.Threads.pas b/Quick.Threads.pas index 2c24992..9015f56 100644 --- a/Quick.Threads.pas +++ b/Quick.Threads.pas @@ -685,7 +685,7 @@ procedure TThreadedQueueCS.Clear; try for obj in FQueue do begin - if TypeInfo(T) = TypeInfo(TObject) then PObject(@obj).Free; + if TypeInfo(T) = TypeInfo(TObject) then PObject(@obj){$ifndef FPC}{$IFDEF DELPHIRX12_UP}.Free{$ELSE}.DisposeOf{$ENDIF}{$ELSE}.Free{$ENDIF}; end; SetLength(FQueue,0);