summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwindowcontainer.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2017-02-26 17:18:40 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2017-02-27 12:38:08 +0000
commitdfc338613ef54de67f2f2b2962d08b0c5a99fcdd (patch)
tree1121a1c16f844b9169bd3eefbf822509830b86fe /src/widgets/kernel/qwindowcontainer.cpp
parente39e4bfc0f49d06e1c742654d2d2f79bab245116 (diff)
Make QPlatformSurface events work with QWindowContainer
Embeddeding a QWindow via QWidget::createWindowContainer() fails to deliver the SurfaceAboutToBeDestroyed event. This breaks any OpenGL or Vulkan based QWindow that releases resources upon this event, and is particularly critical with Vulkan where the only way to do properly ordered swapchain - surface cleanup is via this event. In the non-embedded case close() eventually ends up in an explicit destroy() in QWindow. In the embedded case destroy() only gets called from ~QWindow. This then silently breaks since the subclass' reimplemented event() virtual is not getting called anymore. To remedy the problem, simply add an explicit destroy() to QWindowContainer. Task-number: QTBUG-55166 Change-Id: I1671e8f4d39f6c44e19eca7b9387f55fe3788294 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/widgets/kernel/qwindowcontainer.cpp')
-rw-r--r--src/widgets/kernel/qwindowcontainer.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
index bb25a3a986..7ae63e54b3 100644
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -241,6 +241,14 @@ QWindow *QWindowContainer::containedWindow() const
QWindowContainer::~QWindowContainer()
{
Q_D(QWindowContainer);
+
+ // Call destroy() explicitly first. The dtor would do this too, but
+ // QEvent::PlatformSurface delivery relies on virtuals. Getting
+ // SurfaceAboutToBeDestroyed can be essential for OpenGL, Vulkan, etc.
+ // QWindow subclasses in particular. Keep these working.
+ if (d->window)
+ d->window->destroy();
+
delete d->window;
}