-
Content Count
920 -
Joined
-
Last visited
-
Days Won
56
Everything posted by pyscripter
-
The question still remains why the change in the order results in the Treeview not receiving the WM_DESTROY message. Why is the order important anyway in this issue?
-
@Vincent Parrett@Attila KovacsI am afraid you are both off-topic. If you want to rant about Vcl, Vcl.Styles, Embarcadero etc. please do it in a new thread.
-
ANN: Parnassus Parallel Debugger
pyscripter replied to Dave Millington (personal)'s topic in Delphi Third-Party
@David MillingtonThe features of Parnassus Debugger are great, but I am getting assertion errors with the Parnassus Debugger and Delphi 10.4.2. I am also getting Index out of bounds errors. These occurred while debugging simple Vcl apps (nothing fancy) and they don't occur in the absence of the Parnassus Debugger. Is https://quality.embarcadero.com/ the right place to report issues related to the Parnassus Debugger. -
The issue results from the TListView being recreated as a response to the CM_STYLECHANGED message (see CustomListView.WndProc). If you add the following at the top of UMainForm.pas TListView = class(Vcl.ComCtrls.TListView) protected procedure WndProc(var Message: TMessage); override; end; with the following implementation procedure TListView.WndProc(var Message: TMessage); begin if (Message.Msg = CM_STYLECHANGED) then begin if ViewStyle = vsReport then UpdateColumns; end else inherited; end; the error does not happen. There does not appear to be much point in recreating the ListView, since its handle would have already been recreated, when the form it resides gets recreated. Still it remains a mystery why the recreation of the ListView affects the TreeView! The memory leak is also prevented by calling RecreateWnd after changing the style. In the process of debugging, I discovered another Vcl bug: [RSP-33221] CM_STYLEDCHANGE is broadcast twice - Embarcadero Technologies
-
You need to remove the build event from the project options. This was stated earlier in this thread.
-
This is indeed weird. In fact, just turning the Visible property of the ListView to False prevents the error. Some further observations: I confirm that WMDestroy is not received by the treeview The bug is definitely related to Vcl.Styles. If you change the style to a Vcl.Style and then back to Windows, the error does not occur You can prevent the error by calling Treeview.Items.Clear in the FormCloseQuery event handler. Strangely calling RecreateWnd in the same handler also prevents the error.
-
Issues running Demo Projects on D10.4.2 / Python 3.9.2
pyscripter replied to BastiFantasti's topic in Python4Delphi
You need to add: {$I Definition.inc} to the Demo 31 Unit1.pas It was accidentally deleted in a recent commit. This is now fixed. -
@David MillingtonMaybe you could enlighten us as to the nature of the changes that made the Delphi IDE behave better with RD. Are there any lessons to be learnt by Delphi developers?
-
Issues running Demo Projects on D10.4.2 / Python 3.9.2
pyscripter replied to BastiFantasti's topic in Python4Delphi
Please update to the most recent version. Demo7 is fixed. I can run Demo31 without any issues. -
@Darian Millerhas published a very nice article about the state of TThreadedQueue and TMonitor in Delphi. He has also published at Github a stress test that shows how TThreadQueue still fails under stress. I have played with his stress test and concluded that the problem is almost certainly in TMonitor. TMonitor implements a lock-free stack to recycle events created with the CreateEvent function. The relevant code in SysUtils is var EventCache: PEventItemHolder; EventItemHolders: PEventItemHolder; procedure Push(var Stack: PEventItemHolder; EventItem: PEventItemHolder); var LStack: PEventItemHolder; begin repeat LStack := Stack; EventItem.Next := LStack; until AtomicCmpExchange(Pointer(Stack), EventItem, LStack) = LStack; end; function Pop(var Stack: PEventItemHolder): PEventItemHolder; begin repeat Result := Stack; if Result = nil then Exit; until AtomicCmpExchange(Pointer(Stack), Result.Next, Result) = Result; end; This lock-free stack is used by NewWaitObj and FreeWaitObj which are part of the Monitor support protocol and used by TMonitor. This works reasonably well, but under stress it fails. The reason it fails is known as the ABA problem and is discussed in a similar context by a series of excellent blog posts by @Primož Gabrijelčič: blog post 1, blog post 2, blog post 3. His OmniThreadLibrary contains the following routine that he uses to deal with this problem. /either 8-byte or 16-byte CAS, depending on the platform; destination must be propely aligned (8- or 16-byte) function CAS(const oldData: pointer; oldReference: NativeInt; newData: pointer; newReference: NativeInt; var destination): boolean; asm {$IFNDEF CPUX64} push edi push ebx mov ebx, newData mov ecx, newReference mov edi, destination lock cmpxchg8b qword ptr [edi] pop ebx pop edi {$ELSE CPUX64} .noframe push rbx //rsp := rsp - 8 ! mov rax, oldData mov rbx, newData mov rcx, newReference mov r8, [destination + 8] //+8 with respect to .noframe lock cmpxchg16b [r8] pop rbx {$ENDIF CPUX64} setz al end; { CAS } I have tried to use this function to provide a solution for TMonitor similar to the one in OmniThreadLibrary. (see attached iaStressTest.TThreadedQueue.PopItem that can be used with the original stress test). Whilst still not perfect it helps a lot in 32 bits with say up to 100 threads. However it crashes in 64bits and I do not know why. I am posting this here in case anyone with better knowledge than mine of assembler and thread programming can help with the challenge of fixing TMonitor. It would be nice to try and get a fix included in 10.4. And even if it is not included, it can be easily used as a patch in the same way as in the attached code. iaStressTest.TThreadedQueue.PopItem.pas
-
This makes sense. "Finish incomplete properties" can be very annoying when combined with "Auto invoke" so it is disabled.
-
Could it be that you have unchecked the "Finish incomplete properties"? Works here as expected.
-
No need for any of that, if you are not building applications with run-time packages and most likely you are not. Just change the platform of your project to Win64 and build it.
-
Fixed in version control. See https://github.com/pyscripter/python4delphi/issues/292 Now SystemExit results in a EPySystemExit exception which can be handled in Delphi code. Process termination is prevented.
-
P4D does something similar with custom variants and the Varpyth unit.
-
Which flag do you pass to PyRun_StringFlags?
-
Any reason for not using P4D?
-
All of these suggestions can be implemented without modifying your python code. For example you can just add the suggested code to the PythonEngine.InitScript.
-
@vmishkaYou are using Delphi 10.4 (which is the reason for the problems you are facing). You need to upgrade to 10.4.1 or even better to the just released10.4.2. This is a new installation. You need to download the installer from Registered Products Portal (embarcadero.com)
-
exit() raises the SystemExit exception, which unlike other exceptions, results in process termination before control gets back to Delphi. To prevent process termination you can do one of the following: wrap the python code in a try: except SystemExit: as suggested by @fjames above "overwrite" the exit method by for example running the following code after the python engine is initialized: def _exit(): print("exit prevented") __builtins__.exit = _exit import sys sys.exit = _exit del(_exit) overwrite the SystemExit exception!
-
The design time packages are 32-bit so you need to add the paths to the 32-bit target. The group project contains runtime and designtime packages. You first need to compile/build the runtime packages for target 32-bits. Optionally and only if you want to build 64-bit applications with runtime package, build 64-bit runtime packages: - Python270.bpl - PythonVcl270.bpl - PythonFmx270.bpl Then install the Design time packages (these are always 32-bits) - dclPython270.bpl - dclPythonVcl270.bpl - dclPythonFmx270.bpl
-
10.4.2 Released today - available to download
pyscripter replied to Darian Miller's topic in Tips / Blogs / Tutorials / Videos
I was bitten by this a few times in previous upgrades. This time I knew better... -
10.4.2 Released today - available to download
pyscripter replied to Darian Miller's topic in Tips / Blogs / Tutorials / Videos
I think a (the) highlight of this release is fixing [RSP-27375] Compiler generates disadvantageous code for try/finally - Embarcadero Technologies. Thanks to @Mahdi Safsafifor coming up with a great suggestion and @Stefan Glienkefor creating the issue and pushing hard for its resolution. -
SVGIconImageList/Demo at master · EtheaDev/SVGIconImageList (github.com) is not a bad starting point for debugging. The treeview has no interaction with the rest of the program.
-
In the SvgIconImageList demo case, the application was compiled with the Windows default style and the error occurs when you change the style at runtime. I think that may be significant because it causes the controls to be recreated.