Skip to content

Commit 445de4e

Browse files
committed
1 parent 3b1cf11 commit 445de4e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Source/PythonEngine.pas

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6371,6 +6371,10 @@ constructor TEngineClient.Create( AOwner : TComponent );
63716371

63726372
destructor TEngineClient.Destroy;
63736373
begin
6374+
// if the client is destroyed before the Python Engine then
6375+
// we need to finalize it. Otherwise it will already be finalized
6376+
if FInitialized then
6377+
Finalize;
63746378
Engine := nil; // This detaches the client from the Engine.
63756379
if Assigned( FOnDestroy ) then
63766380
FOnDestroy( Self );
@@ -8647,7 +8651,8 @@ procedure TPythonType.Initialize;
86478651

86488652
procedure TPythonType.Finalize;
86498653
begin
8650-
Engine.Py_CLEAR(FCreateFunc);
8654+
if Assigned(Engine) then
8655+
Engine.Py_CLEAR(FCreateFunc);
86518656
FCreateFunc := nil;
86528657
inherited;
86538658
end;

0 commit comments

Comments
 (0)