Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/PythonQtThreadSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool PythonQtGILScope::_enableGILScope = false;
PythonQtGILScope::PythonQtGILScope()
: _ensured(false)
{
if (_enableGILScope) {
if (_enableGILScope && Py_IsInitialized()) {
Comment thread
usiems marked this conversation as resolved.
_state = PyGILState_Ensure();
_ensured = true;
}
Expand Down
5 changes: 5 additions & 0 deletions tests/PythonQtTestCleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ void PythonQtTestCleanup::testSignalReceiverCleanup()

void PythonQtTestCleanup::testPyFinalizeThenPythonQtCleanup()
{
QVERIFY(_helper->runScript("import PythonQt.QtCore\n"
"timer = PythonQt.QtCore.QTimer(obj)\n"
"timer.connect('destroyed()', obj.onDestroyed)\n"
"obj.setPassed()\n"));

if (Py_IsInitialized()) {
Py_Finalize();
}
Expand Down
8 changes: 4 additions & 4 deletions tests/PythonQtTestMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ int main(int argc, char* argv[])
{
QApplication qapp(argc, argv);

PythonQt::setEnableThreadSupport(QProcessEnvironment::systemEnvironment().contains("PYTHONQT_ENABLE_THREAD_SUPPORT"));

if (QProcessEnvironment::systemEnvironment().contains("PYTHONQT_RUN_ONLY_MEMORY_TESTS")) {
PythonQtMemoryTests test;
QTest::qExec(&test, argc, argv);
return 0;
return QTest::qExec(&test, argc, argv);
}

if (QProcessEnvironment::systemEnvironment().contains("PYTHONQT_RUN_ONLY_CLEANUP_TESTS")) {
PythonQtTestCleanup cleanup;
QTest::qExec(&cleanup, argc, argv);
return 0;
return QTest::qExec(&cleanup, argc, argv);
}

PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
Expand Down
Loading