-
Content Count
853 -
Joined
-
Last visited
-
Days Won
48
pyscripter last won the day on September 12
pyscripter had the most liked content!
Community Reputation
626 ExcellentTechnical Information
-
Delphi-Version
Delphi 12 Athens
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
There is: function TJSONObject.RemovePair(const PairName: string): TJSONPair; To clear all pairs: JsonObject.SetPairs([]); You could also Free the JsonObject and create a new one.
-
New Warning in 12.2: Overloading a similar index type by declaring an array property 'Items'
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
No. -
Does anyone recall in which Delphi version TStringHelper was introduced and in particular TStringHelper.Split? Thanks!
-
SVG Shell Extensions contains examples of how to create Windows File Explorer extensions, both preview and thumbnail.
-
Delphi bug reports or feature requests to "vote"/comment for (important, fatal etc)/
pyscripter replied to Tommi Prami's topic in Delphi IDE and APIs
Thanks, done. -
Delphi bug reports or feature requests to "vote"/comment for (important, fatal etc)/
pyscripter replied to Tommi Prami's topic in Delphi IDE and APIs
For me is three out of three from the new QA fixed: Incorrect Scaling of Vcl.Dialogs.InputQuery - RAD Studio Service - Jira Service Management (atlassian.net) Incorrect Scaling of Vcl.Dialogs.MessageDlg - RAD Studio Service - Jira Service Management (atlassian.net) Internal Compiler error AV5A1299F7(5A060000)-R0000014C-0 - RAD Studio Service - Jira Service Management (atlassian.net) And a couple from the old QA: https://quality.embarcadero.com/browse/RSP-43263 https://quality.embarcadero.com/browse/RSP-41898 -
New Warning in 12.2: Overloading a similar index type by declaring an array property 'Items'
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
No you don't. The index was changed to NativeInt in Delphi 12.0. There are no interface changes in minor versions. It is just the warning that was added in 12.2. Regarding older versions, you are right if you need to support versions before IF was introduced. But many of us including @Carlo Barazzetta don't. -
New Warning in 12.2: Overloading a similar index type by declaring an array property 'Items'
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
So, one approach is to do something like: {$IF (CompilerVersion >= 35) TListSize = NativeInt; {$ELSE} TListSize = Integer; {$END} and then something like: TSynEditMarkList = class(TObjectList) ... property Items[Index: TListSize]: TSynEditMark read GetItem write SetItem; default; end; This would make sure that in all versions of Delphi you do not overload the array property but instead overwrite it. Unintentionally overloading the array property is likely to cause trouble (see earlier post). It also needs just one conditional compilation directive for the whole code base. -
New Warning in 12.2: Overloading a similar index type by declaring an array property 'Items'
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
I am afraid is not that simple. I did the same and when I tried to compile with Delphi 11 64bits, I got compilation errors, not in the declaration but when using the TObjectList descendent. Apparently Delphi implicitly supports indexed property overloading! Hence the name of the warning. Did you know that? I didn't. Example: TSynEditMarkList = class(TObjectList) ... function IsBookmark: Boolean; property Items[Index: NativeInt]: TSynEditMark read GetItem write SetItem; default; end; MarkList: TSynEditMarkList; var I: Integer; J: NativeInt // Both indexed properties, the one defined here and the inherited one can be used as default properties. Mark[I].IsBookmark; // error message IsBookmark is not recognized. Mark[I] is a TObject as in the inherited class. Mark[J].IsBookmark; // works I will probably end up using a generic TList to avoid this mess. -
New Warning in 12.2: Overloading a similar index type by declaring an array property 'Items'
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
I ended up with the following, which is backward compatible and future proof: {$IF (CompilerVersion > 36) or Declared(RTLVersion122)}{$WARN OVERLOADING_ARRAY_PROPERTY OFF}{$ENDIF} property Items[Index : TColumnIndex] : TVirtualTreeColumn read GetItem write SetItem; default; property Header: TVTHeader read FHeader; property TrackIndex : TColumnIndex read FTrackIndex write FTrackIndex; property TreeView : TCustomControl read GetTreeView; property UpdateCount; {$IF (CompilerVersion > 36) or Declared(RTLVersion122)}{$WARN OVERLOADING_ARRAY_PROPERTY ON}{$ENDIF} end; Notes: If the $WARN OFF comes immediately after the Items declaration you still get the warning. Delphi 12.2 still defines RTLVersion121. Presumably if there is a Delphi 12.3 etc. RTLVersion122 will be defined. -
This will no longer work by default in Delphi 12.2. You would need to add to your code: System.TypInfo.GetRecCompareAddrs := System.TypInfo.GetRecordCompareAddrs; Also using {$WEAKLINKRTTI ON} no longer causes crashes. It just results in using the default equality and GetHashCode functions.
-
Weird error with generic TList
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
Delphi 12.2 fixed this. -
New Warning in 12.2: Overloading a similar index type by declaring an array property 'Items'
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
Interestingly the build dialog box reports this as 3 warnings! -
This is the public interface: TParallelArrayForProc<T> = reference to procedure (const AValues: array of T; AFrom, ATo: NativeInt); TParallelArray = class public class procedure &For<T>(const AValues: array of T; const AProc: TParallelArrayForProc<T>); overload; static; class procedure &For<T>(const AValues: array of T; const AProc: TParallelArrayForProc<T>; AIndex, ACount: NativeInt); overload; static; class procedure &For<T>(const AValues: array of T; const AProc: TParallelArrayForProc<T>; AIndex, ACount: NativeInt; APool: TThreadPool; AThreshold: NativeInt); overload; static; class procedure &For<T>(const AValues: TArray<T>; const AProc: TParallelArrayForProc<T>); overload; static; inline; class procedure &For<T>(const AValues: TArray<T>; const AProc: TParallelArrayForProc<T>; AIndex, ACount: NativeInt); overload; static; inline; class procedure &For<T>(const AValues: TArray<T>; const AProc: TParallelArrayForProc<T>; AIndex, ACount: NativeInt; APool: TThreadPool; AThreshold: NativeInt); overload; static; inline; class procedure Sort<T>(var AValues: array of T); overload; static; class procedure Sort<T>(var AValues: array of T; const AComparer: IComparer<T>); overload; static; class procedure Sort<T>(var AValues: array of T; const AComparer: IComparer<T>; AIndex, ACount: NativeInt; APool: TThreadPool); overload; static; class procedure Sort<T>(var AValues: TArray<T>); overload; static; inline; class procedure Sort<T>(var AValues: TArray<T>; const AComparer: IComparer<T>); overload; static; inline; class procedure Sort<T>(var AValues: TArray<T>; const AComparer: IComparer<T>; AIndex, ACount: NativeInt; APool: TThreadPool); overload; static; inline; class property ForThreshold: NativeInt read FForThreshold write FForThreshold default 50000; class property SortThreshold: NativeInt read FSortThreshold write FSortThreshold default 5000; end;
-
New Warning in 12.2: Overloading a similar index type by declaring an array property 'Items'
pyscripter replied to pyscripter's topic in RTL and Delphi Object Pascal
Aha! So is the type of the indexed property that the compiler complains about and not just the fact that you overwrite the inherited indexed property! And it is the change of Integer to NativeInt that caused that.