From ac36261549707c4d8630f0bae1a3416236686531 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 8 Jul 2012 14:03:50 +0200 Subject: [PATCH] Plugins: Calling unload() on app shutdown. --- src/lib/adblock/adblockicon.cpp | 2 +- src/lib/app/mainapplication.cpp | 3 +-- .../desktopnotificationsfactory.cpp | 2 +- .../desktopnotifications/desktopnotificationsfactory.h | 2 +- src/lib/downloads/downloadmanager.cpp | 2 +- src/lib/other/updater.cpp | 2 +- src/lib/plugins/plugins.cpp | 10 ++++++++++ src/lib/plugins/plugins.h | 3 +++ 8 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/lib/adblock/adblockicon.cpp b/src/lib/adblock/adblockicon.cpp index a862744b2..dbc65156e 100644 --- a/src/lib/adblock/adblockicon.cpp +++ b/src/lib/adblock/adblockicon.cpp @@ -61,7 +61,7 @@ void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url) pair.second = url; m_blockedPopups.append(pair); - mApp->desktopNotifications()->showNotifications(QPixmap(":html/adblock_big.png"), tr("Blocked popup window"), tr("AdBlock blocked unwanted popup window.")); + mApp->desktopNotifications()->showNotification(QPixmap(":html/adblock_big.png"), tr("Blocked popup window"), tr("AdBlock blocked unwanted popup window.")); if (!m_flashTimer) { m_flashTimer = new QTimer(this); diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index de9bb1c64..d867e6962 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -619,8 +619,7 @@ void MainApplication::saveSettings() m_searchEnginesManager->saveSettings(); m_networkmanager->saveCertificates(); - m_plugins->c2f_saveSettings(); - m_plugins->speedDial()->saveSettings(); + m_plugins->shutdown(); qIconProvider->saveIconsToDatabase(); AdBlockManager::instance()->save(); diff --git a/src/lib/desktopnotifications/desktopnotificationsfactory.cpp b/src/lib/desktopnotifications/desktopnotificationsfactory.cpp index 19e2ec8f2..140770e7e 100644 --- a/src/lib/desktopnotifications/desktopnotificationsfactory.cpp +++ b/src/lib/desktopnotifications/desktopnotificationsfactory.cpp @@ -49,7 +49,7 @@ void DesktopNotificationsFactory::loadSettings() settings.endGroup(); } -void DesktopNotificationsFactory::showNotifications(const QPixmap &icon, const QString &heading, const QString &text) +void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QString &heading, const QString &text) { if (!m_enabled) { return; diff --git a/src/lib/desktopnotifications/desktopnotificationsfactory.h b/src/lib/desktopnotifications/desktopnotificationsfactory.h index f27a0630a..a27f384bb 100644 --- a/src/lib/desktopnotifications/desktopnotificationsfactory.h +++ b/src/lib/desktopnotifications/desktopnotificationsfactory.h @@ -37,7 +37,7 @@ public: void loadSettings(); - void showNotifications(const QPixmap &icon, const QString &heading, const QString &text); + void showNotification(const QPixmap &icon, const QString &heading, const QString &text); void nativeNotificationPreview(); private: diff --git a/src/lib/downloads/downloadmanager.cpp b/src/lib/downloads/downloadmanager.cpp index 2d621e1b3..539b07a59 100644 --- a/src/lib/downloads/downloadmanager.cpp +++ b/src/lib/downloads/downloadmanager.cpp @@ -257,7 +257,7 @@ void DownloadManager::downloadFinished(bool success) if (downloadingAllFilesFinished) { if (success && qApp->activeWindow() != this) { - mApp->desktopNotifications()->showNotifications(QIcon::fromTheme("mail-inbox", QIcon(":icons/notifications/download.png")).pixmap(48), tr("Download Finished"), tr("All files have been successfully downloaded.")); + mApp->desktopNotifications()->showNotification(QIcon::fromTheme("mail-inbox", QIcon(":icons/notifications/download.png")).pixmap(48), tr("Download Finished"), tr("All files have been successfully downloaded.")); if (!m_closeOnFinish) { raise(); activateWindow(); diff --git a/src/lib/other/updater.cpp b/src/lib/other/updater.cpp index 3eccc403e..c2ad1ca2f 100644 --- a/src/lib/other/updater.cpp +++ b/src/lib/other/updater.cpp @@ -112,7 +112,7 @@ void Updater::downCompleted(QNetworkReply* reply) Version current = parseVersionFromString(QupZilla::VERSION); Version updated = parseVersionFromString(html); if (current < updated) { - mApp->desktopNotifications()->showNotifications(QPixmap(":icons/qupzillaupdate.png"), tr("Update available"), tr("New version of QupZilla is ready to download.")); + mApp->desktopNotifications()->showNotification(QPixmap(":icons/qupzillaupdate.png"), tr("Update available"), tr("New version of QupZilla is ready to download.")); // QAction* action = new QAction(QIcon(":icons/qupzillaupdate.png"), "Update", this); // connect(action, SIGNAL(triggered()), this, SLOT(downloadNewVersion())); // p_QupZilla->menuBar()->addAction(action); diff --git a/src/lib/plugins/plugins.cpp b/src/lib/plugins/plugins.cpp index 6f9354065..efb6365eb 100644 --- a/src/lib/plugins/plugins.cpp +++ b/src/lib/plugins/plugins.cpp @@ -89,6 +89,16 @@ void Plugins::loadSettings() c2f_loadSettings(); } +void Plugins::shutdown() +{ + c2f_saveSettings(); + m_speedDial->saveSettings(); + + foreach(PluginInterface * iPlugin, m_loadedPlugins) { + iPlugin->unload(); + } +} + void Plugins::c2f_loadSettings() { Settings settings; diff --git a/src/lib/plugins/plugins.h b/src/lib/plugins/plugins.h index 4ee119088..9405fa073 100644 --- a/src/lib/plugins/plugins.h +++ b/src/lib/plugins/plugins.h @@ -64,6 +64,8 @@ public: bool loadPlugin(Plugin* plugin); void unloadPlugin(Plugin* plugin); + void shutdown(); + // CLick2Flash void c2f_loadSettings(); void c2f_saveSettings(); @@ -78,6 +80,7 @@ public: public slots: void loadSettings(); + void loadPlugins(); protected: