From 5313017c545445bc3c12521c836e494b4bc09bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Thu, 21 Feb 2019 19:16:28 +0100 Subject: [PATCH] Fix Segfault when jupyter is not installed --- src/common/JupyterConnection.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/JupyterConnection.cpp b/src/common/JupyterConnection.cpp index 9b5685ad..c76e131a 100644 --- a/src/common/JupyterConnection.cpp +++ b/src/common/JupyterConnection.cpp @@ -109,20 +109,23 @@ QVariant JupyterConnection::pollNestedIPyKernel(long id) bool JupyterConnection::startJupyterNotebook() { - Python()->restoreThread(); + PythonManager::ThreadHolder threadHolder; if (!cutterJupyterModule) { cutterJupyterModule = QtResImport("cutter_jupyter"); + if (!cutterJupyterModule) { + qWarning() << "Failed to load cutter_jupyter module. Make sure jupyter is installed."; + return false; + } } - PyObject* startFunc = PyObject_GetAttrString(cutterJupyterModule, "start_jupyter"); + PyObject *startFunc = PyObject_GetAttrString(cutterJupyterModule, "start_jupyter"); if (!startFunc) { qWarning() << "Couldn't get attribute start_jupyter."; return false; } cutterNotebookAppInstance = PyObject_CallObject(startFunc, nullptr); - Python()->saveThread(); return cutterNotebookAppInstance != nullptr; }