From 978fc98bffc0dea5cbe3cdcd49d48726a681dcfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 3 May 2011 12:36:08 +0200 Subject: [PATCH] Fixed bug in X11 backend when creating translucent windows. We forgot to send the ParentAboutToChange event, which meant QGLWidget didn't destroy the old EGL surface. This could cause two EGL surfaces to be created for the same QGLWidget, which leads to undefined behaviour on some platforms. (cherry picked from commit 5a834d7141cc7d29d022911ccec16e628d94acf1) --- src/gui/kernel/qwidget_x11.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 241a13f842e..3eec5c73318 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -952,8 +952,13 @@ static void qt_x11_recreateWidget(QWidget *widget) // recreate their GL context, which in turn causes them to choose // their visual again. Now that WA_TranslucentBackground is set, // QGLContext::chooseVisual will select an ARGB visual. - QEvent e(QEvent::ParentChange); - QApplication::sendEvent(widget, &e); + + // QGLWidget expects a ParentAboutToChange to be sent first + QEvent aboutToChangeEvent(QEvent::ParentAboutToChange); + QApplication::sendEvent(widget, &aboutToChangeEvent); + + QEvent parentChangeEvent(QEvent::ParentChange); + QApplication::sendEvent(widget, &parentChangeEvent); } else { // For regular widgets, reparent them with their parent which // also triggers a recreation of the native window