From bde9387dba244a2bf5324fa22bc5f64f1f0714ea Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 12 Sep 2014 22:26:05 +0200 Subject: Do not drop the context when sharing globally There is no point in recreating the QOpenGLWidget's context when it shares with all top-levels' shareContext(). Change-Id: I659a8ef6563de0cc1e833198af4dfb8c705e40d8 Reviewed-by: Gunnar Sletta --- src/widgets/kernel/qopenglwidget.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/widgets/kernel/qopenglwidget.cpp') diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index bcc3e3592b3..22ea852d99c 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -367,6 +367,10 @@ QT_BEGIN_NAMESPACE from the derived class' destructor, since the slot connected to the signal will not get invoked when the widget is being destroyed. + \note When Qt::AA_ShareOpenGLContexts is set, the widget's context never + changes, not even when reparenting because the widget's associated texture is + guaranteed to be accessible also from the new top-level's context. + Proper cleanup is especially important due to context sharing. Even though each QOpenGLWidget's associated context is destroyed together with the QOpenGLWidget, the sharable resources in that context, like textures, will @@ -1052,6 +1056,8 @@ bool QOpenGLWidget::event(QEvent *e) Q_D(QOpenGLWidget); switch (e->type()) { case QEvent::WindowChangeInternal: + if (qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts)) + break; if (d->initialized) d->reset(); // FALLTHROUGH -- cgit v1.2.3