From 9d7fdfba78fe3f4175f38570019ddb6748983cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matev=C5=BE=20Jekovec?= Date: Sun, 1 Jan 2023 11:14:46 +0100 Subject: [PATCH 1/3] searchdirs: Find scripts in local build directory --- src/canorus.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/canorus.cpp b/src/canorus.cpp index 3e782e7c..bd0ceb9e 100644 --- a/src/canorus.cpp +++ b/src/canorus.cpp @@ -74,6 +74,9 @@ void CACanorus::initSearchPaths() if (cat == "fonts" && QDir(qApp->applicationDirPath() + "/../../src/fonts/").exists()) { QDir::addSearchPath(cat, qApp->applicationDirPath() + "/../../src/fonts/"); } + if (cat == "scripts" && QDir(qApp->applicationDirPath() + "/../../src/scripts/").exists()) { + QDir::addSearchPath(cat, qApp->applicationDirPath() + "/../../src/scripts/"); + } if (cat == "doc" && QDir(qApp->applicationDirPath()).exists("/../../doc/")) { QDir::addSearchPath(cat, qApp->applicationDirPath() + "/../../doc"); } From a7cd6cdaf71416beb6aef176951eb911888b424c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matev=C5=BE=20Jekovec?= Date: Mon, 2 Jan 2023 03:31:24 +0100 Subject: [PATCH 2/3] swigpython: Obtain GIL earlier, force import CanorusPython --- src/scripting/swigpython.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/scripting/swigpython.cpp b/src/scripting/swigpython.cpp index 9cb395c5..d37a6f8b 100644 --- a/src/scripting/swigpython.cpp +++ b/src/scripting/swigpython.cpp @@ -78,6 +78,9 @@ void CASwigPython::init() } #endif + // Load proxy classes. + PyRun_SimpleString("import CanorusPython"); + mainThreadState = PyThreadState_Get(); PyEval_ReleaseThread(mainThreadState); @@ -126,6 +129,8 @@ PyObject* CASwigPython::callFunction(QString fileName, QString function, QList

Date: Mon, 2 Jan 2023 16:21:28 +0100 Subject: [PATCH 3/3] pyconsole: Fix crash on python3.9+ --- src/widgets/pyconsole.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/pyconsole.cpp b/src/widgets/pyconsole.cpp index bb27ba04..30370d8f 100644 --- a/src/widgets/pyconsole.cpp +++ b/src/widgets/pyconsole.cpp @@ -558,8 +558,8 @@ bool CAPyConsole::cmdIntern(QString strCmd) curObject = curObject->parent(); PyEval_RestoreThread(CASwigPython::mainThreadState); argsPython << CASwigPython::toPythonObject(static_cast(curObject)->document(), CASwigPython::Document); - PyEval_ReleaseThread(CASwigPython::mainThreadState); argsPython << PyUnicode_FromString(strCmd.toStdString().c_str()); + PyEval_ReleaseThread(CASwigPython::mainThreadState); // Can't autoreload because we are using global objects in pycl2.py that would get overwritten. auto ret = CASwigPython::callFunction(QFileInfo("scripts:pycl2.py").absoluteFilePath(), "main", argsPython, false);