Commit 775a7096 authored by Laurent Montel's avatar Laurent Montel 😁

Fix crash when we close apps

parent d432db35
...@@ -59,6 +59,5 @@ int main(int argc, char **argv) ...@@ -59,6 +59,5 @@ int main(int argc, char **argv)
ThemeEditorMainWindow *mw = new ThemeEditorMainWindow; ThemeEditorMainWindow *mw = new ThemeEditorMainWindow;
mw->show(); mw->show();
const int ret = app.exec(); const int ret = app.exec();
delete mw;
return ret; return ret;
} }
...@@ -52,6 +52,10 @@ ThemeEditorMainWindow::ThemeEditorMainWindow() ...@@ -52,6 +52,10 @@ ThemeEditorMainWindow::ThemeEditorMainWindow()
} }
ThemeEditorMainWindow::~ThemeEditorMainWindow() ThemeEditorMainWindow::~ThemeEditorMainWindow()
{
}
void ThemeEditorMainWindow::writeConfig()
{ {
KSharedConfig::Ptr config = KSharedConfig::openConfig(); KSharedConfig::Ptr config = KSharedConfig::openConfig();
...@@ -293,6 +297,7 @@ void ThemeEditorMainWindow::closeEvent(QCloseEvent *e) ...@@ -293,6 +297,7 @@ void ThemeEditorMainWindow::closeEvent(QCloseEvent *e)
if (!saveCurrentProject(SaveAndCloseTheme)) { if (!saveCurrentProject(SaveAndCloseTheme)) {
e->ignore(); e->ignore();
} else { } else {
writeConfig();
e->accept(); e->accept();
} }
} }
...@@ -300,6 +305,7 @@ void ThemeEditorMainWindow::closeEvent(QCloseEvent *e) ...@@ -300,6 +305,7 @@ void ThemeEditorMainWindow::closeEvent(QCloseEvent *e)
void ThemeEditorMainWindow::slotQuitApp() void ThemeEditorMainWindow::slotQuitApp()
{ {
if (saveCurrentProject(SaveAndCloseTheme)) { if (saveCurrentProject(SaveAndCloseTheme)) {
writeConfig();
qApp->quit(); qApp->quit();
} }
} }
......
...@@ -62,6 +62,7 @@ private: ...@@ -62,6 +62,7 @@ private:
}; };
bool loadTheme(const QString &directory); bool loadTheme(const QString &directory);
void writeConfig();
void readConfig(); void readConfig();
void updateActions(); void updateActions();
bool saveCurrentProject(ActionSaveTheme act); bool saveCurrentProject(ActionSaveTheme act);
......
...@@ -65,6 +65,5 @@ int main(int argc, char **argv) ...@@ -65,6 +65,5 @@ int main(int argc, char **argv)
ThemeEditorMainWindow *mw = new ThemeEditorMainWindow(); ThemeEditorMainWindow *mw = new ThemeEditorMainWindow();
mw->show(); mw->show();
const int ret = app.exec(); const int ret = app.exec();
delete mw;
return ret; return ret;
} }
...@@ -51,6 +51,10 @@ ThemeEditorMainWindow::ThemeEditorMainWindow() ...@@ -51,6 +51,10 @@ ThemeEditorMainWindow::ThemeEditorMainWindow()
} }
ThemeEditorMainWindow::~ThemeEditorMainWindow() ThemeEditorMainWindow::~ThemeEditorMainWindow()
{
}
void ThemeEditorMainWindow::writeConfig()
{ {
KSharedConfig::Ptr config = KSharedConfig::openConfig(); KSharedConfig::Ptr config = KSharedConfig::openConfig();
...@@ -316,6 +320,7 @@ void ThemeEditorMainWindow::closeEvent(QCloseEvent *e) ...@@ -316,6 +320,7 @@ void ThemeEditorMainWindow::closeEvent(QCloseEvent *e)
if (!saveCurrentProject(SaveAndCloseTheme)) { if (!saveCurrentProject(SaveAndCloseTheme)) {
e->ignore(); e->ignore();
} else { } else {
writeConfig();
e->accept(); e->accept();
} }
} }
...@@ -323,6 +328,7 @@ void ThemeEditorMainWindow::closeEvent(QCloseEvent *e) ...@@ -323,6 +328,7 @@ void ThemeEditorMainWindow::closeEvent(QCloseEvent *e)
void ThemeEditorMainWindow::slotQuitApp() void ThemeEditorMainWindow::slotQuitApp()
{ {
if (saveCurrentProject(SaveAndCloseTheme)) { if (saveCurrentProject(SaveAndCloseTheme)) {
writeConfig();
qApp->quit(); qApp->quit();
} }
} }
......
...@@ -65,6 +65,7 @@ private: ...@@ -65,6 +65,7 @@ private:
bool loadTheme(const QString &directory); bool loadTheme(const QString &directory);
void readConfig(); void readConfig();
void writeConfig();
void updateActions(); void updateActions();
bool saveCurrentProject(ActionSaveTheme act); bool saveCurrentProject(ActionSaveTheme act);
void setupActions(); void setupActions();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment