Jump to content

pyscripter

Members
  • Content Count

    913
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by pyscripter

  1. pyscripter

    Python4Delphi Crash immediately after launch

    That's why we debug programs stepping through the code, To know exactly where the error occurs. And what do you mean crash? Cannot you debug and step into LoadDLL? Or set FatalMsgDlg to True and FatalAbort to False. Do you get an error message? Most likely the python dll fails to load. The most common reason: Are you compiling for 64bits? For more details please read FindingPython · pyscripter/python4delphi Wiki (github.com) Also, could you update python to 3.12.3 and see whether it makes a difference? Needless to say that I cannot reproduce the issue here.
  2. pyscripter

    Python4Delphi Crash immediately after launch

    There is no such code in P4D. Instead: PyWideStringList_Append(PWSL, PWCharT(StringToWCharTString(Paths[I]))); Your code sample above makes no sense. SplitString returns a string array. So code like this: writeln(PansiChar(ansistring(ar))); should contain array indices (e.g. ar[1]). And in any case that code is only executed if you try to set the python path and has been around for quite a while. It is not executed for example by any of the demos. With the latest change Demo36 should work without issues. Again please provide a minimal project that produces errors.
  3. pyscripter

    Python4Delphi Crash immediately after launch

    This was not related to the latest revisions. There was an issue in the Demo related to PythonEngine being destroyed before the threads terminated. This is now fixed in version control. Please try with the latest release and report if the issue has been fixed.
  4. pyscripter

    Python4Delphi Crash immediately after launch

    Which version of P4D are you using? Getit or github and if the latte from which repo? Which version of python? Could you post a minimal project that reproduces the crash?
  5. pyscripter

    P4D Android error

    You need to deploy python to the Android device for this to work. Please see: Embarcadero/PythonEnvironments: Components to simplify the deployment for Python environments for Delphi applications using Python4Delphi. (github.com) and PythonEnvironments/samples/environments/deploy/sample_06_SimpleAndroid at main · Embarcadero/PythonEnvironments (github.com)
  6. pyscripter

    TTaskDialogs not working with Delphi Styles

    As mentioned above, 12.2 works correctly at 300%, But maybe there is an issue when running inside a VM.
  7. pyscripter

    How to release memory used by exceptions?

    This was a reference counting bug. This is now fixed in version control. See Memory leak when PyErr_SetObject is used · Issue #485 · pyscripter/python4delphi (github.com). Could you please try with the latest version and report whether the issue is solved.
  8. pyscripter

    How to release memory used by exceptions?

    Could you please post a minimal project (zipped) demonstrating the memory leak?
  9. pyscripter

    TTaskDialogs not working with Delphi Styles

    I am using the Delphi 12 IDE on a 300% display and I am not observing such issues. In PyScripter I am using the SilverpointDev/sptbxlib: SpTBXLib is an expansion package for TB2K Delphi components that adds multiple features including support for styles and custom skins. (github.com) for menus, which I think is still the best Delphi menu components and work really well with VCL styles and Hi-DPI.
  10. pyscripter

    TTaskDialogs not working with Delphi Styles

    Please allow me to disagree. You can produce good-looking flicker-free and DPI-aware applications with recent versions of Delphi. Have you tried PyScripter for instance? The Delphi IDE is also built with VCL Styles.
  11. pyscripter

    TTaskDialogs not working with Delphi Styles

    https://quality.embarcadero.com/browse/RSP-41990 See also EtheaDev/StyledComponents: Components similar to Delphi VCL Buttons, Toolbar, DbNavigator, BindNavigator, ButtonGroup and CategoryButtons with Custom Graphic Styles, and an advanced, full-customizable TaskDialog, also with animations! (github.com). They contain a Task Dialog can be displayed with Vcl Styles (and many others). File dialogs are styled by VCL though. I am not aware of any major issues.
  12. pyscripter

    InputQuery issue..

    Use the overload without the last argument (which cannot be nil): if InputQuery('User Information', ['Enter your name:', 'Enter your age:', 'Enter your city:'], Values) then
  13. pyscripter

    clear a tjsonobject

    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.
  14. 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?
  15. Does anyone recall in which Delphi version TStringHelper was introduced and in particular TStringHelper.Split? Thanks!
  16. pyscripter

    File Open Dialog Preview

    SVG Shell Extensions contains examples of how to create Windows File Explorer extensions, both preview and thumbnail.
  17. 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
  18. 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.
  19. 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.
  20. 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.
  21. 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.
  22. pyscripter

    Records as TDictionary keys

    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.
  23. The following console app works fine: {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, System.Classes, System.Generics.Collections; type TMethodList = TList<TMethod>; const Method: TMethod = (Code:nil; Data:nil); begin try var fKeyDownChain := TMethodList.Create; try fKeyDownChain.Add(Method); fKeyDownChain.Remove(Method); WriteLn(fKeyDownChain.Count); finally fKeyDownChain.Free; end; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; ReadLn; end. However the exact same sequence results in an access violation when used in a larger Win64 application. const Method: TMethod = (Code:nil; Data:nil); begin fKeyDownChain := TMethodList.Create; fKeyDownChain.Add(Method); fKeyDownChain.Remove(Method); The error occurs when you call Remove, at the first statement of the following function of System.Generics.Defaults, class function TComparer<T>.EQOperCompare(Self: Pointer; const Left, Right: T): Integer; begin if TRecEqualityOperator<T>(_GetExtInstanceData(Self, 0))(Left, Right) then Result := 0 else Result := BinaryCompare(@Left, @Right, SizeOf(T)); end; In the console application this statement results in a call to TMethod.Equal, Any clues as to why the error occurs? Update: This is a consequence of [RSP-43423] Using {$WEAKLINKRTTI ON} causes access violation on TList<T>.IndexOf method - Embarcadero Technologies. The console application also fails with {$WEAKLINKRTTI ON}. I guess specifying a Comparer would be a workaround. Is there any other workaround apart from removing the WEAKLINKRTTI directive, which increases the size of the executable by 2Mb? . Beyond the executable size, this is quite a serious issue, because it makes the use of generic collections of records in components unsafe, since a user of such a component setting WEAKLINKRTTI to ON, could face unpredictable and hard to detect crashes.
×