summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-02-05 00:29:13 +0100
committerAndrea Diamantini <adjam7@gmail.com>2010-02-05 00:29:13 +0100
commitc328e203e0d84177a0028d8ba5b0af4b82c16eeb (patch)
treee6b38cc023c1920a6b2bab87a36ac5932a534ad5 /src
parentMerge commit 'refs/merge-requests/85' of git://gitorious.org/rekonq/mainline (diff)
downloadrekonq-c328e203e0d84177a0028d8ba5b0af4b82c16eeb.tar.xz
QPointers --> QWeakPointers
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp53
-rw-r--r--src/application.h12
-rw-r--r--src/history/historymanager.cpp3
-rw-r--r--src/mainwindow.cpp19
-rw-r--r--src/sessionmanager.cpp4
-rw-r--r--src/settings/settingsdialog.cpp1
-rw-r--r--src/tabbar.cpp29
-rw-r--r--src/tabbar.h4
8 files changed, 66 insertions, 59 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 05004f30..cfd4d060 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -64,10 +64,10 @@
#include <QtCore/QTimer>
-QPointer<HistoryManager> Application::s_historyManager;
-QPointer<BookmarkProvider> Application::s_bookmarkProvider;
-QPointer<SessionManager> Application::s_sessionManager;
-QPointer<AdBlockManager> Application::s_adblockManager;
+QWeakPointer<HistoryManager> Application::s_historyManager;
+QWeakPointer<BookmarkProvider> Application::s_bookmarkProvider;
+QWeakPointer<SessionManager> Application::s_sessionManager;
+QWeakPointer<AdBlockManager> Application::s_adblockManager;
Application::Application()
@@ -80,12 +80,23 @@ Application::Application()
Application::~Application()
{
- qDeleteAll(m_mainWindows);
+ foreach( QWeakPointer<MainWindow> window, m_mainWindows)
+ {
+ delete window.data();
+ window.clear();
+ }
- delete s_bookmarkProvider;
- delete s_historyManager;
- delete s_sessionManager;
- delete s_adblockManager;
+ delete s_bookmarkProvider.data();
+ s_bookmarkProvider.clear();
+
+ delete s_historyManager.data();
+ s_historyManager.clear();
+
+ delete s_sessionManager.data();
+ s_sessionManager.clear();
+
+ delete s_adblockManager.data();
+ s_adblockManager.clear();
}
@@ -145,7 +156,7 @@ int Application::newInstance()
// is there a window open on the current desktop ? use it!
for (int i = 0; i < m_mainWindows.size(); ++i)
{
- MainWindow *m = m_mainWindows.at(i);
+ MainWindow *m = m_mainWindows.at(i).data();
KWindowInfo w = KWindowInfo(m->winId(), NET::WMDesktop);
if(w.isOnCurrentDesktop())
{
@@ -210,7 +221,7 @@ MainWindow *Application::mainWindow()
if(!active)
{
- return m_mainWindows.at(0);
+ return m_mainWindows.at(0).data();
}
return active;
}
@@ -218,38 +229,38 @@ MainWindow *Application::mainWindow()
HistoryManager *Application::historyManager()
{
- if (!s_historyManager)
+ if ( s_historyManager.isNull() )
{
s_historyManager = new HistoryManager();
- QWebHistoryInterface::setDefaultInterface(s_historyManager);
+ QWebHistoryInterface::setDefaultInterface( s_historyManager.data() );
}
- return s_historyManager;
+ return s_historyManager.data();
}
BookmarkProvider *Application::bookmarkProvider()
{
- if (!s_bookmarkProvider)
+ if ( s_bookmarkProvider.isNull() )
{
s_bookmarkProvider = new BookmarkProvider(instance());
}
- return s_bookmarkProvider;
+ return s_bookmarkProvider.data();
}
SessionManager *Application::sessionManager()
{
- if(!s_sessionManager)
+ if( s_sessionManager.isNull() )
{
s_sessionManager = new SessionManager(instance());
}
- return s_sessionManager;
+ return s_sessionManager.data();
}
KIcon Application::icon(const KUrl &url)
{
- if(!Application::instance()->mainWindowList().isEmpty()) // avoid infinite loop at startup
+ if( !Application::instance()->mainWindowList().isEmpty() ) // avoid infinite loop at startup
{
if(url == KUrl("about:closedTabs"))
@@ -355,11 +366,11 @@ MainWindowList Application::mainWindowList()
AdBlockManager *Application::adblockManager()
{
- if(!s_adblockManager)
+ if( s_adblockManager.isNull() )
{
s_adblockManager = new AdBlockManager(instance());
}
- return s_adblockManager;
+ return s_adblockManager.data();
}
diff --git a/src/application.h b/src/application.h
index 4b951ded..0c3bd3f5 100644
--- a/src/application.h
+++ b/src/application.h
@@ -38,7 +38,7 @@
#include <ThreadWeaver/Job>
// Qt Includes
-#include <QPointer>
+#include <QWeakPointer>
#include <QList>
// Forward Declarations
@@ -52,7 +52,7 @@ class AdBlockManager;
class WebView;
-typedef QList< QPointer<MainWindow> > MainWindowList;
+typedef QList< QWeakPointer<MainWindow> > MainWindowList;
namespace Rekonq
@@ -139,10 +139,10 @@ private slots:
void loadResolvedUrl(ThreadWeaver::Job *);
private:
- static QPointer<HistoryManager> s_historyManager;
- static QPointer<BookmarkProvider> s_bookmarkProvider;
- static QPointer<SessionManager> s_sessionManager;
- static QPointer<AdBlockManager> s_adblockManager;
+ static QWeakPointer<HistoryManager> s_historyManager;
+ static QWeakPointer<BookmarkProvider> s_bookmarkProvider;
+ static QWeakPointer<SessionManager> s_sessionManager;
+ static QWeakPointer<AdBlockManager> s_adblockManager;
MainWindowList m_mainWindows;
};
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index 29bdb45b..db19a6b4 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -69,10 +69,9 @@ HistoryManager::HistoryManager(QObject *parent)
, m_historyModel(0)
, m_historyFilterModel(0)
, m_historyTreeModel(0)
- , m_completion(0)
+ , m_completion(new KCompletion)
{
// take care of the completion object
- m_completion = new KCompletion;
m_completion->setOrder( KCompletion::Weighted );
m_expiredTimer.setSingleShot(true);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index df600c05..ffc9f508 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -76,7 +76,7 @@
#include <QtCore/QRect>
#include <QtCore/QSize>
#include <QtCore/QList>
-#include <QtCore/QPointer>
+#include <QtCore/QWeakPointer>
#include <QtGui/QWidget>
#include <QtGui/QVBoxLayout>
@@ -599,13 +599,14 @@ void MainWindow::preferences()
return;
// we didn't find an instance of this dialog, so lets create it
- QPointer<SettingsDialog> s = new SettingsDialog(this);
+ QWeakPointer<SettingsDialog> s = new SettingsDialog(this);
// keep us informed when the user changes settings
- connect(s, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateBrowser()));
+ connect(s.data(), SIGNAL(settingsChanged(const QString&)), this, SLOT(updateBrowser()));
- s->exec();
- delete s;
+ s.data()->exec();
+ delete s.data();
+ s.clear();
}
@@ -1041,16 +1042,16 @@ void MainWindow::notifyMessage(const QString &msg, Rekonq::Notify status)
void MainWindow::clearPrivateData()
{
- QPointer<KDialog> dialog = new KDialog(this, Qt::Sheet);
- dialog->setButtons(KDialog::Ok | KDialog::Cancel);
+ QWeakPointer<KDialog> dialog = new KDialog(this, Qt::Sheet);
+ dialog.data()->setButtons(KDialog::Ok | KDialog::Cancel);
Ui::ClearDataWidget clearWidget;
QWidget widget;
clearWidget.setupUi(&widget);
- dialog->setMainWidget(&widget);
+ dialog.data()->setMainWidget(&widget);
- if (dialog->exec() == KDialog::Accepted)
+ if (dialog.data()->exec() == KDialog::Accepted)
{
if(clearWidget.clearHistory->isChecked())
{
diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp
index f4e7cd3e..f512e943 100644
--- a/src/sessionmanager.cpp
+++ b/src/sessionmanager.cpp
@@ -71,10 +71,10 @@ void SessionManager::saveSession()
}
QTextStream out(&sessionFile);
MainWindowList wl = Application::instance()->mainWindowList();
- Q_FOREACH(QPointer<MainWindow> w, wl)
+ Q_FOREACH(QWeakPointer<MainWindow> w, wl)
{
out << "window\n";
- MainView *mv = w->mainView();
+ MainView *mv = w.data()->mainView();
for (int i = 0 ; i < mv->count() ; i++)
{
out << mv->webTab(i)->url().toEncoded() << "\n";
diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp
index e37481aa..6fab5dcf 100644
--- a/src/settings/settingsdialog.cpp
+++ b/src/settings/settingsdialog.cpp
@@ -53,7 +53,6 @@
#include <KCModuleProxy>
// Qt Includes
-#include <QtCore/QPointer>
#include <QtGui/QWidget>
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index 460a2464..5e1feb56 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -161,24 +161,21 @@ void TabBar::showTabPreview(int tab)
int h = w*((0.0 + currentView->height())/currentView->width());
//delete previous tab preview
- if (m_previewPopup)
- {
- delete m_previewPopup;
- }
-
+ m_previewPopup.clear();
+
m_previewPopup = new KPassivePopup(this);
- m_previewPopup->setFrameShape(QFrame::StyledPanel);
- m_previewPopup->setFrameShadow(QFrame::Plain);
- m_previewPopup->setFixedSize(w, h);
+ m_previewPopup.data()->setFrameShape(QFrame::StyledPanel);
+ m_previewPopup.data()->setFrameShadow(QFrame::Plain);
+ m_previewPopup.data()->setFixedSize(w, h);
QLabel *l = new QLabel();
view->page()->setViewportSize(currentView->page()->viewportSize());
l->setPixmap(WebSnap::renderPreview(*(view->page()), w, h));
- m_previewPopup->setView(l);
- m_previewPopup->layout()->setAlignment(Qt::AlignTop);
- m_previewPopup->layout()->setMargin(0);
+ m_previewPopup.data()->setView(l);
+ m_previewPopup.data()->layout()->setAlignment(Qt::AlignTop);
+ m_previewPopup.data()->layout()->setMargin(0);
QPoint pos( tabRect(tab).x() , tabRect(tab).y() + tabRect(tab).height() );
- m_previewPopup->show(mapToGlobal(pos));
+ m_previewPopup.data()->show(mapToGlobal(pos));
}
@@ -208,9 +205,9 @@ void TabBar::mouseMoveEvent(QMouseEvent *event)
//if current tab or not found then hide previous tab preview
if (tab==currentIndex() || tab==-1)
{
- if ( m_previewPopup)
+ if ( !m_previewPopup.isNull() )
{
- m_previewPopup->hide();
+ m_previewPopup.data()->hide();
}
m_currentTabPreview = -1;
}
@@ -225,9 +222,9 @@ void TabBar::leaveEvent(QEvent *event)
if (ReKonfig::alwaysShowTabPreviews())
{
//if leave tabwidget then hide previous tab preview
- if ( m_previewPopup)
+ if ( !m_previewPopup.isNull() )
{
- m_previewPopup->hide();
+ m_previewPopup.data()->hide();
}
m_currentTabPreview = -1;
}
diff --git a/src/tabbar.h b/src/tabbar.h
index f0476cbd..b57106dc 100644
--- a/src/tabbar.h
+++ b/src/tabbar.h
@@ -35,7 +35,7 @@
#include "rekonqprivate_export.h"
// Qt Includes
-#include <QPointer>
+#include <QWeakPointer>
// KDE Includes
#include <KTabBar>
@@ -99,7 +99,7 @@ private:
*/
int m_actualIndex;
- QPointer<KPassivePopup> m_previewPopup;
+ QWeakPointer<KPassivePopup> m_previewPopup;
int m_currentTabPreview;
};