Fixed bug in X11 backend when creating translucent windows.
authorSamuel Rødal <samuel.rodal@nokia.com>
Tue, 3 May 2011 10:36:08 +0000 (12:36 +0200)
committerOlivier Goffart <olivier.goffart@nokia.com>
Tue, 10 May 2011 10:54:54 +0000 (12:54 +0200)
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

index 241a13f..3eec5c7 100644 (file)
@@ -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