From f559f0400ebd105ef048195e477248ff1f39f6e8 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 7 Aug 2017 12:06:56 +0200 Subject: Close popup windows when their parents are destroyed Previously when a popup window was shown, and the user issued a command to close the only active main window (via a shortcut for example) with a subsequent call to deleteLater(), the main window would be closed and deleted but the popup would only be hidden, which led to the application loop to still be running and not quitting, even though there would be no visible window left. The closing of a popup is usually done in the QWidget destructor when the popup is still visible, but because we unset the parent right before the parent is destroyed (which sets visibility to false), the popup would not be closed, but only hidden. Thus this change makes sure to explicitly close the popup when its parent is destroyed. Task-number: QTBUG-62311 Change-Id: Ia0bbf327929af55aac19767971ab0acde5715e21 Reviewed-by: Viktor Engelmann --- .../render_widget_host_view_qt_delegate_widget.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp') 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 6dd612999..d56f644d3 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -169,7 +169,14 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende void RenderWidgetHostViewQtDelegateWidget::removeParentBeforeParentDelete() { + // Unset the parent, because parent is being destroyed, but the owner of this + // RenderWidgetHostViewQtDelegateWidget is actually a RenderWidgetHostViewQt instance. setParent(Q_NULLPTR); + + // If this widget represents a popup window, make sure to close it, so that if the popup was the + // last visible top level window, the application event loop can quit if it deems it necessarry. + if (m_isPopup) + close(); } void RenderWidgetHostViewQtDelegateWidget::initAsChild(WebContentsAdapterClient* container) -- cgit v1.2.3