-
-
Couldn't load subscription status.
- Fork 324
-
After running a python script, P4D causes an AV error during program shutdown in the following routine...
It seems to be referring to one of my objects as if it support interfaces, which it doesn't.
The object has not been wrapped, so there is nothing to free, it is an internal object created in my app and the properties/methods exposed using the RegisterDelphiWrapper function.
In wrapDelphi unit
procedure TPyDelphiObject.UnSubscribeToFreeNotification;
var
_FreeNotification : IFreeNotification;
begin
Assert(Assigned(fDelphiObject));
if fDelphiObject.GetInterface(IFreeNotification, _FreeNotification) then //<<<< produces AV error
_FreeNotification.UnSubscribe(Self);
end;
In my Python setup I define
PydelphiWrapper1.RegisterDelphiWrapper(TPyClassWrapper<Ttest>).Initialize;
//
p := PyDelphiWrapper1.Wrap(Ttests.create, soOwned);
PythonModule1.SetVar( 'Tests', p );
PythonEngine1.Py_DecRef(p);
Where tests holds and maintains a list of Ttest created in the program by the user.
and the Python code...
import Spam as sp
Tsts = sp.Tests
print(Tsts.Count)
print(Tsts[0].Name)
#a = Tsts[0]
#print(a.Name)
The first print works and creates no error when the program is closed.
If I unhash the commented out line, it works the same, but the error occurs on program shutdown.
I have currently worked around this by by wrapping the P4D line that causes the error with a try/except
procedure TPyDelphiObject.UnSubscribeToFreeNotification;
var
_FreeNotification : IFreeNotification;
begin
Assert(Assigned(fDelphiObject));
try
if fDelphiObject.GetInterface(IFreeNotification, _FreeNotification) then
_FreeNotification.UnSubscribe(Self);
except
end;
end;
Which allows the program to shutdown properly but a bit annoying when running under debugging.
is there a way to stop this function being called on shutdown when they shouldn't be ?
Beta Was this translation helpful? Give feedback.
All reactions
Hi, took me a long time to track this down, but it appears to be a problem with Synedit rather than P4D.
It was a weird one, having between 70 and 81 characters in the editor caused the problem on shutdown.
I didn't even need to run any python code and it still did it, it must be a memory corruption caused by the editor.
It seems the version of SynEdit I had dated back to 2014, I have upgraded to the latest and the problem has gone away.
Replies: 3 comments
-
Could you please post a Delphi project that reproduces the error?
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi, I'll try and create a standalone simple project that reproduces the error.
Strangely, I have found that adding more python lines of code stops the error from occurring, it only seems to happen on the first access to a delphi object and providing no other accesses are made.
Beta Was this translation helpful? Give feedback.
All reactions
-
Hi, took me a long time to track this down, but it appears to be a problem with Synedit rather than P4D.
It was a weird one, having between 70 and 81 characters in the editor caused the problem on shutdown.
I didn't even need to run any python code and it still did it, it must be a memory corruption caused by the editor.
It seems the version of SynEdit I had dated back to 2014, I have upgraded to the latest and the problem has gone away.
Beta Was this translation helpful? Give feedback.