Partially fix shutting down Python

This commit is contained in:
Florian Märkl 2019-02-03 14:00:40 +01:00
parent da3e1fad29
commit 1c98a1c42e
4 changed files with 23 additions and 17 deletions

View File

@ -170,8 +170,13 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
CutterApplication::~CutterApplication() CutterApplication::~CutterApplication()
{ {
QList<CutterPlugin *> plugins = Core()->getCutterPlugins();
for (CutterPlugin *plugin : plugins) {
delete plugin;
}
delete mainWindow; delete mainWindow;
delete Python(); Python()->shutdown();
} }
bool CutterApplication::event(QEvent *e) bool CutterApplication::event(QEvent *e)
@ -220,8 +225,8 @@ void CutterApplication::loadPlugins()
Python()->addPythonPath(pluginsDir.absolutePath().toLatin1().data()); Python()->addPythonPath(pluginsDir.absolutePath().toLatin1().data());
CutterPlugin *cutterPlugin = nullptr;
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) { foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
CutterPlugin *cutterPlugin = nullptr;
if (fileName.endsWith(".py")) { if (fileName.endsWith(".py")) {
// Load python plugins // Load python plugins
QStringList l = fileName.split(".py"); QStringList l = fileName.split(".py");
@ -241,7 +246,7 @@ void CutterApplication::loadPlugins()
} }
} }
qInfo() << "Loaded" << plugins.length() << "plugins."; qInfo() << "Loaded" << plugins.length() << "plugin(s).";
Core()->setCutterPlugins(plugins); Core()->setCutterPlugins(plugins);
} }

View File

@ -25,20 +25,6 @@ PythonManager::PythonManager()
PythonManager::~PythonManager() PythonManager::~PythonManager()
{ {
QList<CutterPlugin *> plugins = Core()->getCutterPlugins();
for (CutterPlugin *plugin : plugins) {
delete plugin;
}
restoreThread();
emit willShutDown();
Py_Finalize();
if (pythonHome) {
PyMem_RawFree(pythonHome);
}
} }
void PythonManager::initPythonHome() void PythonManager::initPythonHome()
@ -85,6 +71,19 @@ void PythonManager::initialize()
saveThread(); saveThread();
} }
void PythonManager::shutdown()
{
emit willShutDown();
restoreThread();
Py_Finalize();
if (pythonHome) {
PyMem_RawFree(pythonHome);
}
}
void PythonManager::addPythonPath(char *path) { void PythonManager::addPythonPath(char *path) {
restoreThread(); restoreThread();

View File

@ -21,6 +21,8 @@ public:
void initPythonHome(); void initPythonHome();
void initialize(); void initialize();
void shutdown();
void addPythonPath(char *path); void addPythonPath(char *path);