From a91470576dbeaf1e649ea776b2ccc364f7cb51e1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 21 Jun 2020 01:39:39 +0200 Subject: [PATCH] [skip ci] make Jupyter notebook integration working again --- src/Main/FreeCADGuiPy.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Main/FreeCADGuiPy.cpp b/src/Main/FreeCADGuiPy.cpp index a1d2079743..32f82207a6 100644 --- a/src/Main/FreeCADGuiPy.cpp +++ b/src/Main/FreeCADGuiPy.cpp @@ -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;