diff options
Diffstat (limited to 'sources')
-rw-r--r-- | sources/shiboken2/libshiboken/qapp_macro.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sources/shiboken2/libshiboken/qapp_macro.cpp b/sources/shiboken2/libshiboken/qapp_macro.cpp index 306f53b74..c2018bd6f 100644 --- a/sources/shiboken2/libshiboken/qapp_macro.cpp +++ b/sources/shiboken2/libshiboken/qapp_macro.cpp @@ -246,7 +246,14 @@ NotifyModuleForQApp(PyObject *module, void *qApp) * qApp_contents variable and assigns the instance, instead of vice-versa. */ PyObject *coreDict = qApp_moduledicts[1]; - if (qApp != nullptr && coreDict != nullptr) { + if (coreDict == nullptr) { + // PYSIDE-1135: Make sure that at least QtCore gets imported. + // That problem exists when a derived instance is created in C++. + qApp_moduledicts[1] = Py_None; // anything != nullptr during import + coreDict = PyImport_ImportModule("PySide2.QtCore"); + qApp_moduledicts[1] = coreDict; + } + if (qApp != nullptr && coreDict != nullptr && coreDict != Py_None) { PyObject *coreApp = PyDict_GetItemString(coreDict, "QCoreApplication"); if (coreApp != nullptr) { qApp_content = PyObject_CallMethod(coreApp, "instance", ""); |