From 52f381191684c36f1985b835026172a8d16ca074 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Mon, 29 Sep 2014 18:23:42 +0200 Subject: [PATCH] SpeedDial: Save using AutoSaver Prevents losing dials in case of crash. --- CHANGELOG | 1 + src/lib/app/mainapplication.cpp | 4 +++- src/lib/plugins/plugins.cpp | 1 - src/lib/plugins/speeddial.cpp | 9 +++++++++ src/lib/plugins/speeddial.h | 5 ++++- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index aab440f24..ac59edd4a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ Version 1.8.1 * not yet released * fixed: autofill not working for some frames + * fixed: saving speed dial in case of crash * fixed: building on Mac Version 1.8.0 diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 71482fa73..1b4a6a3f6 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -294,6 +294,9 @@ MainApplication::~MainApplication() // Delete all classes that are saving data in destructor delete m_bookmarks; delete m_cookieJar; + delete m_plugins; + + Settings::syncSettings(); } bool MainApplication::isClosing() const @@ -761,7 +764,6 @@ void MainApplication::saveSettings() qzSettings->saveSettings(); AdBlockManager::instance()->save(); QFile::remove(DataPaths::currentProfilePath() + QLatin1String("/WebpageIcons.db")); - Settings::syncSettings(); } void MainApplication::messageReceived(const QString &message) diff --git a/src/lib/plugins/plugins.cpp b/src/lib/plugins/plugins.cpp index d40301146..a134a7138 100644 --- a/src/lib/plugins/plugins.cpp +++ b/src/lib/plugins/plugins.cpp @@ -93,7 +93,6 @@ void Plugins::loadSettings() void Plugins::shutdown() { c2f_saveSettings(); - m_speedDial->saveSettings(); foreach (PluginInterface* iPlugin, m_loadedPlugins) { iPlugin->unload(); diff --git a/src/lib/plugins/speeddial.cpp b/src/lib/plugins/speeddial.cpp index 38373155b..9dd9035f8 100644 --- a/src/lib/plugins/speeddial.cpp +++ b/src/lib/plugins/speeddial.cpp @@ -20,6 +20,7 @@ #include "settings.h" #include "datapaths.h" #include "qztools.h" +#include "autosaver.h" #include #include @@ -38,6 +39,14 @@ SpeedDial::SpeedDial(QObject* parent) , m_loaded(false) , m_regenerateScript(true) { + m_autoSaver = new AutoSaver(this); + connect(m_autoSaver, SIGNAL(save()), this, SLOT(saveSettings())); + connect(this, SIGNAL(pagesChanged()), m_autoSaver, SLOT(changeOcurred())); +} + +SpeedDial::~SpeedDial() +{ + m_autoSaver->saveIfNecessary(); } void SpeedDial::loadSettings() diff --git a/src/lib/plugins/speeddial.h b/src/lib/plugins/speeddial.h index 109c0613d..e641cb43e 100644 --- a/src/lib/plugins/speeddial.h +++ b/src/lib/plugins/speeddial.h @@ -27,6 +27,7 @@ class QUrl; class QWebFrame; class QPixmap; +class AutoSaver; class PageThumbnailer; class QUPZILLA_EXPORT SpeedDial : public QObject @@ -44,9 +45,9 @@ public: }; explicit SpeedDial(QObject* parent = 0); + ~SpeedDial(); void loadSettings(); - void saveSettings(); Page pageForUrl(const QUrl &url); QUrl urlForShortcut(int key); @@ -81,6 +82,7 @@ public slots: private slots: void thumbnailCreated(const QPixmap &pixmap); + void saveSettings(); private: QString escapeTitle(QString string) const; @@ -99,6 +101,7 @@ private: QList > m_webFrames; QList m_webPages; + AutoSaver* m_autoSaver; bool m_loaded; bool m_regenerateScript;