Skip to content

Instantly share code, notes, and snippets.

Created October 19, 2009 14:01
Show Gist options
  • Save anonymous/213396 to your computer and use it in GitHub Desktop.
Save anonymous/213396 to your computer and use it in GitHub Desktop.
From b2658e3ac5951eab8d22cc1193a3c293ed0c88fc Mon Sep 17 00:00:00 2001
From: Antonio Gomes <tonikitoo@webkit.org>
Date: Mon, 19 Oct 2009 09:51:20 -0400
Subject: [PATCH] QWebPage's view object can easily become a dangling pointer since it can not be
owned by the qwebpage object itself nor by qwebview (or qgraphicswebview).
Patch by Antonio Gomes <tonikitoo@webkit.org> on 2009-10-19
Reviewed by NOBODY (OOPS!).
Patch makes QWebPagePrivate's view object to be a QPointer. That way qwebpage's 'view'
object is set to '0' after it gets deleted.
"Guarded pointers are useful whenever you need to store a pointer to a QObject that is
owned by someone else, and therefore might be destroyed while you still hold a
reference to it".
* Api/qwebpage.cpp:
(QWebPage::view):
* Api/qwebpage_p.h:
---
WebKit/qt/Api/qwebpage.cpp | 2 +-
WebKit/qt/Api/qwebpage_p.h | 2 +-
WebKit/qt/ChangeLog | 18 ++++++++++++++++++
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/WebKit/qt/Api/qwebpage.cpp b/WebKit/qt/Api/qwebpage.cpp
index 6a589c0..19c8bf4 100644
--- a/WebKit/qt/Api/qwebpage.cpp
+++ b/WebKit/qt/Api/qwebpage.cpp
@@ -1678,7 +1678,7 @@ void QWebPage::setView(QWidget *view)
*/
QWidget *QWebPage::view() const
{
- return d->view;
+ return d->view.data();
}
/*!
diff --git a/WebKit/qt/Api/qwebpage_p.h b/WebKit/qt/Api/qwebpage_p.h
index b9571fa..c98e32d 100644
--- a/WebKit/qt/Api/qwebpage_p.h
+++ b/WebKit/qt/Api/qwebpage_p.h
@@ -135,7 +135,7 @@ public:
#ifndef QT_NO_UNDOSTACK
QUndoStack *undoStack;
#endif
- QWidget* view;
+ QPointer<QWidget> view;
bool insideOpenCall;
quint64 m_totalBytes;
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 972839d..1bdb1c9 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,21 @@
+2009-10-19 Antonio Gomes <tonikitoo@webkit.org>
+
+ Reviewed by NOBODY (OOPS!).
+
+ QWebPage's view object can easily become a dangling pointer since it can not be
+ owned by the qwebpage object itself nor by qwebview (or qgraphicswebview).
+
+ Patch makes QWebPagePrivate's view object to be a QPointer. That way qwebpage's 'view'
+ object is set to '0' after it gets deleted.
+
+ "Guarded pointers are useful whenever you need to store a pointer to a QObject that is
+ owned by someone else, and therefore might be destroyed while you still hold a
+ reference to it".
+
+ * Api/qwebpage.cpp:
+ (QWebPage::view):
+ * Api/qwebpage_p.h:
+
2009-10-19 Girish Ramakrishnan <girish@forwardbias.in>
Reviewed by Holger Freyther.
--
1.6.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment