summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-05-04 09:19:16 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-05-04 09:19:16 +0200
commit7ea1b6add7ebef4d475801e15e89992e734617c1 (patch)
treea083886be1493a1616ef380e8ccad40e09e49e1f /src
parentFix conflicts (diff)
downloadrekonq-7ea1b6add7ebef4d475801e15e89992e734617c1.tar.xz
Memory leaks fixes
first bunch
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/bookmarkcontextmenu.cpp6
-rw-r--r--src/bookmarks/bookmarkcontextmenu.h3
-rw-r--r--src/bookmarks/bookmarksmanager.cpp9
-rw-r--r--src/bookmarks/bookmarkspanel.cpp9
-rw-r--r--src/bookmarks/bookmarkstreemodel.cpp2
-rw-r--r--src/bookmarks/bookmarkstreemodel.h2
-rw-r--r--src/findbar.cpp4
-rw-r--r--src/history/historymanager.cpp6
-rw-r--r--src/history/historypanel.cpp23
-rw-r--r--src/mainview.cpp2
-rw-r--r--src/mainwindow.cpp31
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/protocolhandler.cpp22
-rw-r--r--src/urlbar/rsswidget.cpp36
-rw-r--r--src/urlbar/rsswidget.h18
-rw-r--r--src/webtab.cpp44
-rw-r--r--src/webtab.h2
17 files changed, 137 insertions, 84 deletions
diff --git a/src/bookmarks/bookmarkcontextmenu.cpp b/src/bookmarks/bookmarkcontextmenu.cpp
index df8bf5e0..47608710 100644
--- a/src/bookmarks/bookmarkcontextmenu.cpp
+++ b/src/bookmarks/bookmarkcontextmenu.cpp
@@ -49,6 +49,12 @@ BookmarkContextMenu::BookmarkContextMenu(const KBookmark & bookmark, KBookmarkMa
}
+BookmarkContextMenu::~BookmarkContextMenu()
+{
+ delete m_ac;
+}
+
+
void BookmarkContextMenu::setupActions()
{
KAction* action;
diff --git a/src/bookmarks/bookmarkcontextmenu.h b/src/bookmarks/bookmarkcontextmenu.h
index c8c903d8..ebbfd6e8 100644
--- a/src/bookmarks/bookmarkcontextmenu.h
+++ b/src/bookmarks/bookmarkcontextmenu.h
@@ -40,6 +40,8 @@ class BookmarkContextMenu : public KBookmarkContextMenu
public:
BookmarkContextMenu(const KBookmark & bk, KBookmarkManager * manager, KBookmarkOwner *owner, QWidget * parent = 0);
+ ~BookmarkContextMenu();
+
virtual void addActions();
private slots:
@@ -59,6 +61,7 @@ private:
void addFolderActions();
void addBookmarkActions();
void addSeparatorActions();
+
KActionCollection *m_ac;
};
diff --git a/src/bookmarks/bookmarksmanager.cpp b/src/bookmarks/bookmarksmanager.cpp
index 73127257..bfa8d238 100644
--- a/src/bookmarks/bookmarksmanager.cpp
+++ b/src/bookmarks/bookmarksmanager.cpp
@@ -302,6 +302,8 @@ BookmarkProvider::~BookmarkProvider()
delete m_actionCollection;
delete m_owner;
delete m_manager;
+
+ delete m_completion;
}
@@ -363,11 +365,8 @@ void BookmarkProvider::contextMenu(const QPoint &point)
if (!action)
return;
- KMenu *menu = new BookmarkContextMenu(action->bookmark(), bookmarkManager(), bookmarkOwner());
- if (!menu)
- return;
-
- menu->popup(bookmarkToolBar->mapToGlobal(point));
+ BookmarkContextMenu menu(action->bookmark(), bookmarkManager(), bookmarkOwner());
+ menu.exec(bookmarkToolBar->mapToGlobal(point));
}
diff --git a/src/bookmarks/bookmarkspanel.cpp b/src/bookmarks/bookmarkspanel.cpp
index 0f4e64b8..502af574 100644
--- a/src/bookmarks/bookmarkspanel.cpp
+++ b/src/bookmarks/bookmarkspanel.cpp
@@ -188,8 +188,13 @@ void BookmarksPanel::contextMenu(const QPoint &pos)
KBookmark selected = bookmarkForIndex(index);
- BookmarkContextMenu *menu = new BookmarkContextMenu(selected, Application::bookmarkProvider()->bookmarkManager(), Application::bookmarkProvider()->bookmarkOwner(), this);
- menu->popup(m_treeView->mapToGlobal(pos));
+ BookmarkContextMenu menu( selected,
+ Application::bookmarkProvider()->bookmarkManager(),
+ Application::bookmarkProvider()->bookmarkOwner(),
+ this
+ );
+
+ menu.exec(m_treeView->mapToGlobal(pos));
}
diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp
index 654069c2..06732007 100644
--- a/src/bookmarks/bookmarkstreemodel.cpp
+++ b/src/bookmarks/bookmarkstreemodel.cpp
@@ -330,7 +330,7 @@ void BookmarksTreeModel::populate(BtmItem *node, KBookmarkGroup bmg)
}
-KBookmark BookmarksTreeModel::bookmarkForIndex(const QModelIndex index) const
+KBookmark BookmarksTreeModel::bookmarkForIndex(const QModelIndex &index) const
{
return static_cast<BtmItem*>(index.internalPointer())->getBkm();
}
diff --git a/src/bookmarks/bookmarkstreemodel.h b/src/bookmarks/bookmarkstreemodel.h
index d066e137..8dd0923c 100644
--- a/src/bookmarks/bookmarkstreemodel.h
+++ b/src/bookmarks/bookmarkstreemodel.h
@@ -97,7 +97,7 @@ private:
void resetModel();
void setRoot(KBookmarkGroup bmg);
void populate(BtmItem *node, KBookmarkGroup bmg);
- KBookmark bookmarkForIndex(const QModelIndex index) const;
+ KBookmark bookmarkForIndex(const QModelIndex &index) const;
};
#endif // BOOKMARKSTREEMODEL_H
diff --git a/src/findbar.cpp b/src/findbar.cpp
index db97f87d..f89cde60 100644
--- a/src/findbar.cpp
+++ b/src/findbar.cpp
@@ -119,6 +119,10 @@ FindBar::FindBar(QWidget *parent)
FindBar::~FindBar()
{
+ delete m_lineEdit;
+ delete m_hideTimer;
+ delete m_matchCase;
+ delete m_highlightAll;
}
diff --git a/src/history/historymanager.cpp b/src/history/historymanager.cpp
index 8dc7e049..e7e80841 100644
--- a/src/history/historymanager.cpp
+++ b/src/history/historymanager.cpp
@@ -94,6 +94,12 @@ HistoryManager::~HistoryManager()
{
m_saveTimer->saveIfNeccessary();
delete m_completion;
+
+ delete m_saveTimer;
+
+ delete m_historyModel;
+ delete m_historyFilterModel;
+ delete m_historyTreeModel;
}
diff --git a/src/history/historypanel.cpp b/src/history/historypanel.cpp
index 4c4982e9..c8009afd 100644
--- a/src/history/historypanel.cpp
+++ b/src/history/historypanel.cpp
@@ -122,44 +122,39 @@ void HistoryPanel::setup()
void HistoryPanel::contextMenuItem(const QPoint &pos)
{
- KMenu *menu = new KMenu(this);
+ KMenu menu;
KAction* action;
action = new KAction(KIcon("tab-new"), i18n("Open"), this);
connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInCurrentTab()));
- menu->addAction(action);
+ menu.addAction(action);
action = new KAction(KIcon("tab-new"), i18n("Open in New Tab"), this);
connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewTab()));
- menu->addAction(action);
+ menu.addAction(action);
action = new KAction(KIcon("window-new"), i18n("Open in New Window"), this);
connect(action, SIGNAL(triggered()), m_treeView, SLOT(openInNewWindow()));
- menu->addAction(action);
+ menu.addAction(action);
action = new KAction(KIcon("edit-copy"), i18n("Copy Link Address"), this);
connect(action, SIGNAL(triggered()), m_treeView, SLOT(copyToClipboard()));
- menu->addAction(action);
+ menu.addAction(action);
- if (!menu)
- return;
- menu->popup(m_treeView->mapToGlobal(pos));
+ menu.exec(m_treeView->mapToGlobal(pos));
}
void HistoryPanel::contextMenuGroup(const QPoint &pos)
{
- KMenu *menu = new KMenu(this);
+ KMenu menu;
KAction* action;
action = new KAction(KIcon("tab-new"), i18n("Open Folder in Tabs"), this);
connect(action, SIGNAL(triggered()), this, SLOT(openAll()));
+ menu.addAction(action);
- menu->addAction(action);
-
- if (!menu)
- return;
- menu->popup(m_treeView->mapToGlobal(pos));
+ menu.exec(m_treeView->mapToGlobal(pos));
}
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 4dc95b26..6179af80 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -102,6 +102,8 @@ MainView::MainView(MainWindow *parent)
MainView::~MainView()
{
+ delete _bars;
+ delete m_addTabButton;
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 28c7dff1..a598128b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -157,8 +157,27 @@ MainWindow::~MainWindow()
{
Application::bookmarkProvider()->removeToolBar(m_bmBar);
Application::instance()->removeMainWindow(this);
- delete m_popup;
+
+ delete m_view;
+ delete m_findBar;
+
+ delete m_historyPanel;
+ delete m_bookmarksPanel;
+ delete m_webInspectorPanel;
+
+ delete m_stopReloadAction;
+ delete m_historyBackMenu;
delete m_encodingMenu;
+
+ delete m_mainBar;
+ delete m_bmBar;
+
+ delete m_zoomSlider;
+
+ delete m_popup;
+ delete m_hidePopup;
+
+ delete m_ac;
}
@@ -168,7 +187,7 @@ void MainWindow::setupToolbars()
m_mainBar->addAction(actionByName(KStandardAction::name(KStandardAction::Back)));
m_mainBar->addAction(actionByName(KStandardAction::name(KStandardAction::Forward)));
m_mainBar->addSeparator();
- m_mainBar->addAction(actionByName("stop_reload"));
+ m_mainBar->addAction(actionByName( QL1S("stop_reload") ));
m_mainBar->addAction(actionByName(KStandardAction::name(KStandardAction::Home)));
// location bar
@@ -176,8 +195,8 @@ void MainWindow::setupToolbars()
urlBarAction->setDefaultWidget(m_view->urlBarWidget());
m_mainBar->addAction(urlBarAction);
- m_mainBar->addAction(actionByName("bookmarksActionMenu"));
- m_mainBar->addAction(actionByName("rekonq_tools"));
+ m_mainBar->addAction(actionByName( QL1S("bookmarksActionMenu") ));
+ m_mainBar->addAction(actionByName( QL1S("rekonq_tools") ));
m_mainBar->show(); // this just to fix reopening rekonq after fullscreen close
@@ -691,7 +710,7 @@ void MainWindow::privateBrowsing(bool enable)
}
else
{
- actionCollection()->action("private_browsing")->setChecked(false);
+ actionCollection()->action( QL1S("private_browsing") )->setChecked(false);
}
}
else
@@ -1014,7 +1033,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
}
-QAction *MainWindow::actionByName(const QString name)
+QAction *MainWindow::actionByName(const QString &name)
{
QAction *ret = actionCollection()->action(name);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 0f0fea96..6ca4cbfb 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -71,7 +71,7 @@ public:
MainView *mainView() const;
WebTab *currentTab() const;
- QAction *actionByName(const QString name);
+ QAction *actionByName(const QString &name);
virtual QSize sizeHint() const;
virtual KActionCollection *actionCollection() const;
void setWidgetsVisible(bool makeFullScreen);
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp
index 51bd7e9a..82d39225 100644
--- a/src/protocolhandler.cpp
+++ b/src/protocolhandler.cpp
@@ -73,6 +73,7 @@ ProtocolHandler::ProtocolHandler(QObject *parent)
ProtocolHandler::~ProtocolHandler()
{
+ delete _lister;
}
@@ -189,6 +190,9 @@ bool ProtocolHandler::postHandling(const QNetworkRequest &request, QWebFrame *fr
QFileInfo fileInfo(_url.path());
if (fileInfo.isDir())
{
+ if(_lister)
+ delete _lister;
+
_lister = new KDirLister;
connect(_lister, SIGNAL(newItems(const KFileItemList &)), this, SLOT(showResults(const KFileItemList &)));
_lister->openUrl(_url);
@@ -209,15 +213,16 @@ void ProtocolHandler::showResults(const KFileItemList &list)
if (!_lister->rootItem().isNull() && _lister->rootItem().isReadable() && _lister->rootItem().isFile())
{
emit downloadUrl(_lister->rootItem().url());
- return;
}
+ else
+ {
+ QString html = dirHandling(list);
+ _frame->setHtml(html, _url);
- QString html = dirHandling(list);
- _frame->setHtml(html, _url);
-
- Application::instance()->mainWindow()->currentTab()->setFocus();
- Application::historyManager()->addHistoryEntry(_url.prettyUrl());
-
+ Application::instance()->mainWindow()->currentTab()->setFocus();
+ Application::historyManager()->addHistoryEntry(_url.prettyUrl());
+ }
+
delete _lister;
}
@@ -308,6 +313,9 @@ void ProtocolHandler::slotMostLocalUrlResult(KJob *job)
KIO::UDSEntry entry = statJob->statResult();
if (entry.isDir())
{
+ if(_lister)
+ delete _lister;
+
_lister = new KDirLister;
connect(_lister, SIGNAL(newItems(const KFileItemList &)), this, SLOT(showResults(const KFileItemList &)));
_lister->openUrl(_url);
diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp
index 1cce6e8c..395d7bab 100644
--- a/src/urlbar/rsswidget.cpp
+++ b/src/urlbar/rsswidget.cpp
@@ -51,7 +51,7 @@
-RSSWidget::RSSWidget(QMap< KUrl, QString > map, QWidget *parent)
+RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent)
: QFrame(parent, Qt::Popup)
, m_map(map)
{
@@ -87,23 +87,31 @@ RSSWidget::RSSWidget(QMap< KUrl, QString > map, QWidget *parent)
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Add Feed"));
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(accepted()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
layout->addWidget(buttonBox);
}
-void RSSWidget::showAt(QPoint pos)
+RSSWidget::~RSSWidget()
{
- pos.setX(pos.x() - 200);
- pos.setY(pos.y() + 10);
- move(pos);
+ delete m_agregators;
+ delete m_feeds;
+}
+
+
+void RSSWidget::showAt(const QPoint &pos)
+{
+ QPoint p;
+ p.setX(pos.x() - 200);
+ p.setY(pos.y() + 10);
+ move(p);
show();
}
-void RSSWidget::accepted()
+void RSSWidget::accept()
{
QString url = m_map.key(m_feeds->currentText()).toMimeDataString();
@@ -112,18 +120,25 @@ void RSSWidget::accepted()
else
addWithGoogleReader(url);
+ reject();
+}
+
+
+void RSSWidget::reject()
+{
close();
+ this->deleteLater();
}
-void RSSWidget::addWithGoogleReader(QString url)
+void RSSWidget::addWithGoogleReader(const QString &url)
{
KUrl toLoad = KUrl("http://www.google.com/ig/add?feedurl=" + url);
Application::instance()->mainWindow()->currentTab()->view()->load(toLoad);
}
-void RSSWidget::addWithAkregator(QString url)
+void RSSWidget::addWithAkregator(const QString &url)
{
// Akregator is running
if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.akregator"))
@@ -151,4 +166,3 @@ void RSSWidget::addWithAkregator(QString url)
}
}
-
diff --git a/src/urlbar/rsswidget.h b/src/urlbar/rsswidget.h
index 258107eb..0272805e 100644
--- a/src/urlbar/rsswidget.h
+++ b/src/urlbar/rsswidget.h
@@ -46,16 +46,18 @@ class RSSWidget : public QFrame
public:
// QMap< feedUrl, feedTitle>
- RSSWidget(QMap<KUrl, QString> map, QWidget *parent);
-
- void showAt(QPoint pos);
-
-public slots:
- void accepted();
+ RSSWidget(const QMap<KUrl, QString> &map, QWidget *parent = 0);
+ ~RSSWidget();
+
+ void showAt(const QPoint &pos);
+private slots:
+ void accept();
+ void reject();
+
private:
- void addWithAkregator(QString url);
- void addWithGoogleReader(QString url);
+ void addWithAkregator(const QString &url);
+ void addWithGoogleReader(const QString &url);
QMap<KUrl, QString> m_map;
diff --git a/src/webtab.cpp b/src/webtab.cpp
index e03fb72f..d8fff875 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -63,28 +63,22 @@
WebTab::WebTab(QWidget *parent)
: QWidget(parent)
+ , _view(new WebView(this))
, m_progress(0)
{
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+
QVBoxLayout *l = new QVBoxLayout(this);
l->setMargin(0);
l->setSpacing(0);
- QWidget *messageBar = new QWidget(this);
- l->addWidget(messageBar);
- messageBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
-
- QVBoxLayout *l2 = new QVBoxLayout(messageBar);
- l2->setMargin(0);
- l2->setSpacing(0);
-
- WebView *view = new WebView(this);
- l->addWidget(view);
- view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ l->addWidget(_view);
+ _view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// fix focus handling
- setFocusProxy(view);
+ setFocusProxy(_view);
- KWebWallet *wallet = view->page()->wallet();
+ KWebWallet *wallet = _view->page()->wallet();
if (wallet)
{
@@ -92,8 +86,8 @@ WebTab::WebTab(QWidget *parent)
this, SLOT(createWalletBar(const QString &, const QUrl &)));
}
- connect(view, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int)));
- connect(view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
+ connect(_view, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int)));
+ connect(_view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
}
@@ -104,8 +98,7 @@ WebTab::~WebTab()
WebView *WebTab::view()
{
- WebView *view = qobject_cast<WebView *>(layout()->itemAt(1)->widget());
- return view;
+ return _view;
}
@@ -168,11 +161,9 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url)
return;
KWebWallet *wallet = page()->wallet();
- QWidget *messageBar = layout()->itemAt(0)->widget();
-
- WalletBar *walletBar = new WalletBar(messageBar);
+ WalletBar *walletBar = new WalletBar(this);
walletBar->onSaveFormData(key, url);
- messageBar->layout()->addWidget(walletBar);
+ qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, walletBar);
connect(walletBar, SIGNAL(saveFormDataAccepted(const QString &)),
wallet, SLOT(acceptSaveFormDataRequest(const QString &)));
@@ -183,10 +174,9 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url)
void WebTab::createPreviewSelectorBar(int index)
{
- QWidget *messageBar = layout()->itemAt(0)->widget();
- PreviewSelectorBar *bar = new PreviewSelectorBar(index, messageBar);
- messageBar->layout()->addWidget(bar);
-
+ PreviewSelectorBar *bar = new PreviewSelectorBar(index, this);
+ qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, bar);
+
connect(page(), SIGNAL(loadStarted()), bar, SLOT(loadProgress()));
connect(page(), SIGNAL(loadProgress(int)), bar, SLOT(loadProgress()));
connect(page(), SIGNAL(loadFinished(bool)), bar, SLOT(loadFinished()));
@@ -211,7 +201,7 @@ void WebTab::showRSSInfo(QPoint pos)
col.append(page()->mainFrame()->findAllElements("link[type=\"application/atom+xml\"]"));
QMap<KUrl, QString> map;
- int i = 0;
+
foreach(QWebElement el, col)
{
QString urlString;
@@ -232,8 +222,6 @@ void WebTab::showRSSInfo(QPoint pos)
title = el.attribute("href");
map.insert(KUrl(urlString), title);
-
- i++;
}
RSSWidget *widget = new RSSWidget(map, window());
diff --git a/src/webtab.h b/src/webtab.h
index 10b8fe94..309ecd9a 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -68,6 +68,8 @@ private slots:
void showRSSInfo(QPoint pos);
private:
+ WebView *_view;
+
int m_progress;
};