From a013b8f0a260ebedbd74f76bd43b0384ca5e2bc4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Feb 2010 12:10:25 +0100 Subject: Save memory. One WebPage pointer less for each WebView :) --- src/webview.cpp | 19 +++++++++++++------ src/webview.h | 3 +-- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/webview.cpp b/src/webview.cpp index 36f62bfa..e39ff32e 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -62,16 +62,16 @@ WebView::WebView(QWidget* parent) : KWebView(parent, false) - , m_page( new WebPage(this) ) - , m_mousePos(QPoint(0,0)) + , m_mousePos( QPoint(0,0) ) { - setPage(m_page); + WebPage *page = new WebPage(this); + setPage(page); // download system connect(this, SIGNAL(linkShiftClicked(const KUrl &)), - m_page, SLOT(downloadUrl(const KUrl &))); - connect(m_page, SIGNAL(downloadRequested(const QNetworkRequest &)), - m_page, SLOT(downloadRequest(const QNetworkRequest &))); + page, SLOT(downloadUrl(const KUrl &))); + connect(page, SIGNAL(downloadRequested(const QNetworkRequest &)), + page, SLOT(downloadRequest(const QNetworkRequest &))); // middle click || ctrl + click signal connect(this, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), @@ -89,6 +89,13 @@ WebView::~WebView() } +WebPage *WebView::page() +{ + WebPage *page = qobject_cast( KWebView::page() ); + return page; +} + + void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult result = page()->mainFrame()->hitTestContent(event->pos()); diff --git a/src/webview.h b/src/webview.h index 1598b19c..6d75c549 100644 --- a/src/webview.h +++ b/src/webview.h @@ -46,7 +46,7 @@ public: explicit WebView(QWidget *parent); ~WebView(); - WebPage *page() { return m_page; } + WebPage *page(); QPoint mousePos(); protected: @@ -71,7 +71,6 @@ signals: void loadUrl(const KUrl &, const Rekonq::OpenType &); private: - WebPage *const m_page; QPoint m_mousePos; }; -- cgit v1.2.1