-
Content Count
1005 -
Joined
-
Last visited
-
Days Won
66
Posts posted by pyscripter
-
-
Does anyone recall in which Delphi version TStringHelper was introduced and in particular TStringHelper.Split?
Thanks!
-
48 minutes ago, Uwe Raabe said:In case you think about creating your own previews used by Windows Explorer
SVG Shell Extensions contains examples of how to create Windows File Explorer extensions, both preview and thumbnail.
-
1
-
-
2 hours ago, Tommi Prami said:IF possible, check your tickets on the new Jira, that they are visible to others also...
Thanks, done.
-
1
-
-
1 hour ago, dummzeuch said:At least one of my bug reports got resolved in Delphi 12
For me is three out of three from the new QA fixed:
And a couple from the old QA:
-
1
-
-
1 hour ago, Angus Robertson said:You still need {$IF Declared(RTLVersion122)} if you want the component to also work on 12.0 and 12.1.
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.
-
1 hour ago, Angus Robertson said:{$DEFINE TListNatInt}
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.
-
On 9/12/2024 at 9:16 PM, Angus Robertson said:Assuming the warning relates to TList,Items[Index] changing from Integer to NativeInt, I created alternative versions of the SetItem and GetItem functions with NativeInt.
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.
-
7 hours ago, Kas Ob. said:This warning/error is here forever, i suggest to do yourself a favor and rewrite the above with future proof parameters.
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.
-
2
-
On 6/24/2024 at 6:28 PM, balabuev said:Did you know that the following will automatically work with TDictionary:
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.
-
Delphi 12.2 fixed this.
-
-
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;
-
1
-
-
22 minutes ago, Angus Robertson said:Assuming the warning relates to TList,Items[Index] changing from Integer to NativeInt, I created alternative versions of the SetItem and GetItem functions with NativeInt.
Our library needs to support older versions like 12.1 without warnings so DEFINES for 12.2 and later complicate it, you can probably just change a few Integers to NativeInt.
Angus
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.
-
1 hour ago, Angus Robertson said:have added alternative NativeInt versions of the Items property for D12.2 and later
Could you please give an example of what you did?
-
1 hour ago, Kas Ob. said:No issue there, just simple error.
Great. Swap a warning in 12.2 with an error in earlier versions.
-
1
-
-
1 hour ago, Uwe Raabe said:{$WARN OVERLOADING_ARRAY_PROPERTY OFF}
Will this not cause an issue with earlier DELPHI versions?
-
1
-
-
The following code (from VirtualTrees) raises a new warning in Delphi 12.2:
TVirtualTreeColumns = class(TCollection) ... property Items[Index : TColumnIndex] : TVirtualTreeColumn read GetItem write SetItem; default; ... end
The warning says:
[dcc64 Warning] VirtualTrees.Header.pas(280): W1075 Overloading a similar index type by declaring an array property 'Items' VirtualTrees.Header.pas(280): Related member: property TVirtualTreeColumns.Items[TColumnIndex]: TVirtualTreeColumn; VirtualTrees.Header.pas(280): Related member: property TCollection.Items[Integer]: TCollectionItem;
I get quite a few similar warnings in my code base.
Clearly the overwriting (and not overloading) is intentional. Any ideas of how to get rid of this warning without suppressing it?
-
6 minutes ago, Uwe Raabe said:Remember to manually uninstall all Parnassus plugins before you start the update!
Forgot to do that. How can I fix it now?
Update:
Deleted Parnassus entries from Registry and now it works. Very annoying.
-
-
You can set ReportMemoryLeaksOnShutdown to True to see whether there are leaks on the Delphi side.
Loading and unloading the python dll multiple times is not a good idea. There is no guarantee that it will release all allocated memory when it unloads and it does not unload all other dlls loaded by python. It was designed to be loaded once in a single process.
And there is no need to do that. Your program will be faster and leaner if you reuse the python dll.
-
The GetIt version is created by Embarcadero based on a p4d fork. Eventually the fixes will be added to the Embacadero fork, but then it may take some time for the GetIt installation to be updated. Using the pyscripter/python4delphi: Free components that wrap up Python into Delphi and Lazarus (FPC) (github.com) repo will probably get you the latest fixes much faster.
-
You can create instances of classes in the "pythonic" way:
myform = Form()
TForm.Create() is not supported (TForm is exposed in python as Form).
-
OnData is called from a thread. You need to change it to:
procedure TForm2.OnData(Sender: TObject; const Data: string);
begin
TThread.Synchronize(nil,
procedure
begin
Memo1.Lines.Add(Data); //No
Memo1.Lines.Add('2'); //No
end);
end;Also set DelayWrites to False. DelayWrites only makes sense with TPythonGUIInputOutput.
With the above two changes your code works as expected.
-
Can you post a zip file with your project?
New Warning in 12.2: Overloading a similar index type by declaring an array property 'Items'
in RTL and Delphi Object Pascal
Posted
No.