mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user