diff options
Diffstat (limited to 'src/useragent')
-rw-r--r-- | src/useragent/useragentmanager.cpp | 16 | ||||
-rw-r--r-- | src/useragent/useragentmanager.h | 3 |
2 files changed, 11 insertions, 8 deletions
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 |