mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 10:58:51 +00:00
Fix JupyterConnection Shutdown on Error
This commit is contained in:
parent
47e99f6d11
commit
9434476c11
@ -25,17 +25,17 @@ JupyterConnection::JupyterConnection(QObject *parent) : QObject(parent)
|
|||||||
|
|
||||||
JupyterConnection::~JupyterConnection()
|
JupyterConnection::~JupyterConnection()
|
||||||
{
|
{
|
||||||
if (cutterNotebookAppInstance)
|
if (pyThreadState)
|
||||||
{
|
{
|
||||||
PyEval_RestoreThread(pyThreadState);
|
PyEval_RestoreThread(pyThreadState);
|
||||||
|
|
||||||
|
if (cutterNotebookAppInstance)
|
||||||
|
{
|
||||||
auto stopFunc = PyObject_GetAttrString(cutterNotebookAppInstance, "stop");
|
auto stopFunc = PyObject_GetAttrString(cutterNotebookAppInstance, "stop");
|
||||||
PyObject_CallObject(stopFunc, nullptr);
|
PyObject_CallObject(stopFunc, nullptr);
|
||||||
Py_DECREF(cutterNotebookAppInstance);
|
Py_DECREF(cutterNotebookAppInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Py_IsInitialized())
|
|
||||||
{
|
|
||||||
Py_Finalize();
|
Py_Finalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,20 +63,22 @@ void JupyterConnection::createCutterJupyterModule()
|
|||||||
auto moduleCodeObject = Py_CompileString(moduleCode.constData(), "cutter_jupyter.py", Py_file_input);
|
auto moduleCodeObject = Py_CompileString(moduleCode.constData(), "cutter_jupyter.py", Py_file_input);
|
||||||
if (!moduleCodeObject)
|
if (!moduleCodeObject)
|
||||||
{
|
{
|
||||||
|
PyErr_Print();
|
||||||
qWarning() << "Could not compile cutter_jupyter.";
|
qWarning() << "Could not compile cutter_jupyter.";
|
||||||
emit creationFailed();
|
emit creationFailed();
|
||||||
pyThreadState = PyEval_SaveThread();
|
pyThreadState = PyEval_SaveThread();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cutterJupyterModule = PyImport_ExecCodeModule("cutter_jupyter", moduleCodeObject);
|
cutterJupyterModule = PyImport_ExecCodeModule("cutter_jupyter", moduleCodeObject);
|
||||||
Py_DECREF(moduleCodeObject);
|
|
||||||
if (!cutterJupyterModule)
|
if (!cutterJupyterModule)
|
||||||
{
|
{
|
||||||
|
PyErr_Print();
|
||||||
qWarning() << "Could not import cutter_jupyter.";
|
qWarning() << "Could not import cutter_jupyter.";
|
||||||
emit creationFailed();
|
emit creationFailed();
|
||||||
pyThreadState = PyEval_SaveThread();
|
pyThreadState = PyEval_SaveThread();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Py_DECREF(moduleCodeObject);
|
||||||
|
|
||||||
pyThreadState = PyEval_SaveThread();
|
pyThreadState = PyEval_SaveThread();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user