Skip to content

Application crash on macOS after closing the Py-QT5 window. #409

Open
@HawaiAl

Description

@HawaiAl

Hello.
There is a big problem with macOS Ventura 13.1.
I've made the simplest app for macOS 64-bit - one Form, one Button. It executes a very simple python script.

Everything works fine, but after closing the chart window, the application crashes with a message in a PAServer:
objc_disposeClassPair: class 'FMXWindow' still has subclasses, including 'NSKVONotifying_FMXWindow’!

In larger projects, the effect is stranger. What can be done to solve this problem?

P.S. It is also interesting that after running the script, the application icon changes to the Matplotlib icon.

unit MainUnit;
interface
uses
   PythonEngine,
   System.Classes,
   FMX.Forms, FMX.Controls, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Types;

type
   TFormMain = class(TForm)
      ButtonRun: TButton;
      procedure FormCreate(Sender: TObject);
      procedure ButtonRunClick(Sender: TObject);
      private
         py: TPythonEngine;
   end;

var
   FormMain: TFormMain;

implementation
{$R *.fmx}

procedure TFormMain.FormCreate(Sender: TObject);
begin
   // Create python engine
   py                     := TPythonEngine.Create(Self);
   py.UseLastKnownVersion := True;
   py.FatalAbort          := False;
   py.FatalMsgDlg         := False;
   // Load DLL
   py.LoadDll;
end;

procedure TFormMain.ButtonRunClick(Sender: TObject);
begin
   // Simple script, that uses matplotlib and Py-QT5
   var s: ANSIString := 'import matplotlib.pyplot as plt'#10
         + 'plt.plot([1.6, 2.7])'#10
         + 'plt.show()';
   py.ExecString(s);
end;

end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions