python not getting initialized bug in 2.0
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
With 2.0 version now receiving:
"Fatal Python error: PyThreadState_Get: no current thread"
on e.g. PyGettingStarted example
Appears that Py_Initialize is not getting invoked. Commenting out these lines fixes the problem:
//if (flags & PythonAlreadyInitialized == 0) {
Py_SetProgramName("PythonQt");
if (flags & IgnoreSiteModule) {
// this prevents the automatic importing of Python site files
Py_NoSiteFlag = 1;
}
qDebug() << "Py_Initialize() start";
Py_Initialize();
qDebug() << "Py_Initialize() done";
//}
You are right, the correct line is
if ((flags & PythonAlreadyInitialized) == 0) {
…
}
I added this as a last minute feature and it broke PythonQt… I fixed it and uploaded PythonQt 2.0.1.
Lesson learned: Run your tests before releasing, even if it is late in the night…
At first I assumed this was a build problem on my end (e.g. pointing to incorrect dlls). I glanced over that code more than once before seeing the issue. So clearly the lesson learned is that C++ bitwise operators need to be given higher precedence ;-)