Fix Segfault when jupyter is not installed

This commit is contained in:
Florian Märkl 2019-02-21 19:16:28 +01:00
parent 3cdc6a5230
commit 5313017c54

View File

@ -109,10 +109,14 @@ 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");
@ -122,7 +126,6 @@ bool JupyterConnection::startJupyterNotebook()
}
cutterNotebookAppInstance = PyObject_CallObject(startFunc, nullptr);
Python()->saveThread();
return cutterNotebookAppInstance != nullptr;
}