[skip ci] make Jupyter notebook integration working again

This commit is contained in:
wmayer
2020-06-21 01:39:39 +02:00
parent 4b8cf63c14
commit 3971c85130

View File

@@ -120,17 +120,20 @@ FreeCADGui_showMainWindow(PyObject * /*self*/, PyObject *args)
t.detach();
}
else {
// In order to get Jupiter notebook integration working we must create a direct instance
// of QApplication. Not even a sub-class can be used because otherwise PySide2 wraps it
// with a QtCore.QCoreApplication which will raise an exception in ipykernel
#if defined(Q_OS_WIN)
static int argc = 0;
static char **argv = {0};
(void)new QtApplication(argc, argv);
(void)new QApplication(argc, argv);
// When QApplication is constructed
hhook = SetWindowsHookEx(WH_GETMESSAGE,
FilterProc, 0, GetCurrentThreadId());
#elif !defined(QT_NO_GLIB)
static int argc = 0;
static char **argv = {0};
(void)new QtApplication(argc, argv);
(void)new QApplication(argc, argv);
#else
PyErr_SetString(PyExc_RuntimeError, "Must construct a QApplication before a QPaintDevice\n");
return NULL;