Address Python and PySide API changes

This commit is contained in:
Anton Kochkov 2023-02-16 12:42:32 +08:00 committed by Anton Kochkov
parent 553a8eef5c
commit 93f88263a0
2 changed files with 8 additions and 1 deletions

View File

@ -111,6 +111,8 @@ if(CUTTER_ENABLE_PYTHON)
find_package(Shiboken6Tools "${Shiboken6_VERSION_REQUIRED}" REQUIRED)
find_package(PySide6 "${Shiboken6_VERSION_REQUIRED}" REQUIRED)
get_target_property(PYSIDE_INCLUDE_DIR PySide6::pyside6 INTERFACE_INCLUDE_DIRECTORIES)
# Check the presence of "pysidecleanup.h"
CHECK_INCLUDE_FILE_CXX("pysidecleanup.h" HAVE_PYSIDECLEANUP)
else()
# 5.12.3 => 5.12
if("${Qt5_VERSION}" MATCHES "^([0-9]+\\.[0-9]+)\\.[0-9]+")

View File

@ -13,6 +13,10 @@
#ifdef CUTTER_ENABLE_PYTHON_BINDINGS
# include <shiboken.h>
# include <pyside.h>
#ifdef HAVE_PYSIDECLEANUP
// This header is introduced in PySide 6
# include <pysidecleanup.h>
#endif
# include <signalmanager.h>
#endif
@ -72,6 +76,7 @@ void PythonManager::initialize()
PyImport_AppendInittab("CutterBindings", &PyInit_CutterBindings);
#endif
Py_Initialize();
// This function is deprecated does nothing starting from Python 3.9
PyEval_InitThreads();
pyThreadStateCounter = 1; // we have the thread now => 1
@ -159,7 +164,7 @@ void PythonManager::addPythonPath(char *path)
if (!append) {
return;
}
PyEval_CallFunction(append, "(s)", path);
PyObject_CallFunction(append, "(s)", path);
saveThread();
}