path: root/src
diff options
authorJocelyn Turcotte <>2014-05-06 19:33:45 +0200
committerThe Qt Project <>2014-05-07 18:54:59 +0200
commit388a71d66f31df999dc9259d4eb156c497ad5247 (patch)
tree4fe335e569bdc43c12821587f07265f79cca0c58 /src
parentf5ad05b1a5c878a943e82109f60526c8b909a1a7 (diff)
Properly cleanup the old page when attaching a new one
This patch fixes two issues: - The RWHV delegate of the old page would not be detached from the view when attaching a new page to that view. Call reattachRWHV as we do on the new page to make sure that the delegate gets unparented from the view. - QtWebKit documents that a page having the view as its QObject parent should be deleted when setPage is called with a new page. This would cause QupZilla to leak the page when opening a new window through a link. This also adds a workaround to avoid a crash when unparenting the delegate where QOpenGLWidget would try to call paintGL without a valid QSurface. Change-Id: Icd2659f441d2220c26dc175d66424e6c26125861 Reviewed-by: Andras Becsi <>
Diffstat (limited to 'src')
2 files changed, 8 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index 3e6efafbd..47afca8ce 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -72,6 +72,9 @@ void QWebEngineViewPrivate::bind(QWebEngineView *view, QWebEnginePage *page)
if (QWebEnginePage *oldPage = view->d_func()->page) {
oldPage->d_func()->view = 0;
+ oldPage->d_func()->adapter->reattachRWHV();
+ if (oldPage->parent() == view)
+ delete oldPage;
view->d_func()->page = page;
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 7c012e54c..6c3f1cb1c 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -192,6 +192,11 @@ void RenderWidgetHostViewQtDelegateWidget::initializeGL()
void RenderWidgetHostViewQtDelegateWidget::paintGL()
+ // A workaround for a missing check in 5.3.0 when updating an unparented delegate.
+ if (!QOpenGLContext::currentContext())
+ return;
QSGNode *paintNode = m_client->updatePaintNode(rootNode->firstChild(),;
if (paintNode != rootNode->firstChild()) {
delete rootNode->firstChild();