Only initialise Python once

When switching instances, the Python runner gets another initPython call, despite the previous interpreter existing. Most of the function was either a no-op or was redundant, and the GIL state got confusing. This is the simplest fix.

If things catch fire that I haven't anticipated, instead of returning true, we can destroy the pre-existing interpreter and create a new one by running the rest of the function.
This commit is contained in:
AnyOldName3
2020-04-16 00:53:29 +01:00
parent 2e13cf0dab
commit 5825661a4f
+2
View File
@@ -1347,6 +1347,8 @@ BOOST_PYTHON_MODULE(moprivate)
bool PythonRunner::initPython(const QString &pythonPath)
{
if (Py_IsInitialized())
return true;
try {
if (!pythonPath.isEmpty() && !QFile::exists(pythonPath + "/python.exe")) {
return false;