diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-07-27 08:55:21 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-07-27 08:55:21 +0200 |
commit | 37b95a4e10ca0af39a03b17e974baf72f1b4c7c7 (patch) | |
tree | 8845a61f47317115945a103eefd574dd6f3ba29d /src | |
parent | This should fix local files launch by console when rekonq is just loaded (diff) | |
download | rekonq-37b95a4e10ca0af39a03b17e974baf72f1b4c7c7.tar.xz |
Fix sneaky crash of user agent menu
BUG: 303862
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 14 | ||||
-rw-r--r-- | src/useragent/useragentmanager.cpp | 16 | ||||
-rw-r--r-- | src/useragent/useragentmanager.h | 3 |
3 files changed, 24 insertions, 9 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ad11e1af..7e42e6c1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1598,7 +1598,19 @@ void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::populateUserAgentMenu() { KMenu *uaMenu = static_cast<KMenu *>(QObject::sender()); - rApp->userAgentManager()->populateUAMenuForTabUrl(uaMenu, currentTab()); + if (!uaMenu) + { + kDebug() << "oops... NO user agent menu"; + return; + } + WebTab *w = currentTab(); + if (!w) + { + kDebug() << "oh oh... NO current tab. What is it happening here???"; + return; + } + + rApp->userAgentManager()->populateUAMenuForTabUrl(uaMenu, w); } diff --git a/src/useragent/useragentmanager.cpp b/src/useragent/useragentmanager.cpp index 37bc496a..9a2db3c9 100644 --- a/src/useragent/useragentmanager.cpp +++ b/src/useragent/useragentmanager.cpp @@ -43,7 +43,6 @@ UserAgentManager::UserAgentManager(QObject *parent) : QObject(parent) , m_uaSettingsAction(0) - , m_uaTab(0) { m_uaSettingsAction = new KAction(KIcon("preferences-web-browser-identification"), i18n("Browser Identification"), this); connect(m_uaSettingsAction, SIGNAL(triggered(bool)), this, SLOT(showSettings())); @@ -52,7 +51,7 @@ UserAgentManager::UserAgentManager(QObject *parent) void UserAgentManager::showSettings() { - QPointer<KDialog> dialog = new KDialog(m_uaTab); + QPointer<KDialog> dialog = new KDialog(m_uaTab.data()); dialog->setCaption(i18nc("@title:window", "User Agent Settings")); dialog->setButtons(KDialog::Ok); @@ -66,11 +65,14 @@ void UserAgentManager::showSettings() void UserAgentManager::populateUAMenuForTabUrl(KMenu *uaMenu, WebTab *uaTab) { - if (m_uaTab) - disconnect(this, SIGNAL(reloadTab()), m_uaTab->view(), SLOT(reload())); + if (!m_uaTab.isNull()) + { + disconnect(this, SIGNAL(reloadTab()), m_uaTab.data()->view(), SLOT(reload())); + m_uaTab.clear(); + } m_uaTab = uaTab; - connect(this, SIGNAL(reloadTab()), m_uaTab->view(), SLOT(reload())); + connect(this, SIGNAL(reloadTab()), m_uaTab.data()->view(), SLOT(reload())); bool defaultUA = true; @@ -109,7 +111,7 @@ void UserAgentManager::populateUAMenuForTabUrl(KMenu *uaMenu, WebTab *uaTab) UserAgentInfo uaInfo; QStringList UAlist = uaInfo.availableUserAgents(); const KService::List providers = uaInfo.availableProviders(); - int uaIndex = uaInfo.uaIndexForHost(m_uaTab->url().host()); + int uaIndex = uaInfo.uaIndexForHost(m_uaTab.data()->url().host()); for (int i = 0; i < UAlist.count(); ++i) { @@ -166,6 +168,6 @@ void UserAgentManager::setUserAgent() int uaIndex = sender->data().toInt(); UserAgentInfo uaInfo; - uaInfo.setUserAgentForHost(uaIndex, m_uaTab->url().host()); + uaInfo.setUserAgentForHost(uaIndex, m_uaTab.data()->url().host()); emit reloadTab(); } diff --git a/src/useragent/useragentmanager.h b/src/useragent/useragentmanager.h index 6037cc7c..57a65c31 100644 --- a/src/useragent/useragentmanager.h +++ b/src/useragent/useragentmanager.h @@ -30,6 +30,7 @@ // Qt Includes #include <QObject> +#include <QWeakPointer> // Forward Declarations class WebTab; @@ -56,7 +57,7 @@ Q_SIGNALS: private: KAction *m_uaSettingsAction; - WebTab *m_uaTab; + QWeakPointer<WebTab> m_uaTab; }; #endif // USER_AGENT_MANAGER_H |