diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-22 12:17:15 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-29 08:23:24 +0000 |
commit | a174ed2a996bf6311e849c8d8f31bbe307c6838b (patch) | |
tree | 8ff2bfe9a83ac06cd79fd44187a5dab1efaba235 /src/quickwidgets | |
parent | 285007f9687ef8aca6faed89f0c56696c2612548 (diff) |
Handle AA_ShareOpenGLContexts consistently in QQuickWidget
QOpenGLWidget has offered a lot more fine-grained control over the lifetime
of the OpenGL context it uses for rendering. In practice QQuickWidget also
requires at least a part of this. To unify the behavior when it comes to
reparenting to a different top-level window, add the bail out condition for
AA_ShareOpenGLContexts to QQuickWidget as well.
[ChangeLog][QtQuick][Important Behavior Changes] QQuickWidget now behaves
identically to QOpenGLWidget when it comes to handling window changes when
reparenting the widget into a hierarchy belonging to another top-level
widget. Previously the OpenGL context always got destroyed and recreated
in order to ensure texture resource sharing with the new top-level widget.
From now on this is only true when when AA_ShareOpenGLContexts it not set.
Task-number: QTBUG-54133
Change-Id: Ifda0db76fdf71dae1b9606fb5d59cee6edc2f5a4
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quickwidgets')
-rw-r--r-- | src/quickwidgets/qquickwidget.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 4a98122fea..9dba007540 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -154,7 +154,18 @@ void QQuickWidgetPrivate::invalidateRenderControl() void QQuickWidgetPrivate::handleWindowChange() { + if (offscreenWindow->isPersistentSceneGraph() && qGuiApp->testAttribute(Qt::AA_ShareOpenGLContexts)) + return; + + // In case of !isPersistentSceneGraph or when we need a new context due to + // the need to share resources with the new window's context, we must both + // invalidate the scenegraph and destroy the context. With + // QQuickRenderControl destroying the context must be preceded by an + // invalidate to prevent being left with dangling context references in the + // rendercontrol. + invalidateRenderControl(); + if (!useSoftwareRenderer) destroyContext(); } @@ -417,6 +428,20 @@ QObject *QQuickWidgetPrivate::focusObject() persistent. The OpenGL context is thus not destroyed when hiding the widget. The context is destroyed only when the widget is destroyed or when the widget gets reparented into another top-level widget's child hierarchy. + However, some applications, in particular those that have their own + graphics resources due to performing custom OpenGL rendering in the Qt + Quick scene, may wish to disable the latter since they may not be prepared + to handle the loss of the context when moving a QQuickWidget into another + window. Such applications can set the + QCoreApplication::AA_ShareOpenGLContexts attribute. For a discussion on the + details of resource initialization and cleanup, refer to the QOpenGLWidget + documentation. + + \note QQuickWidget offers less fine-grained control over its internal + OpenGL context than QOpenGLWidget, and there are subtle differences, most + notably that disabling the persistent scene graph will lead to destroying + the context on a window change regardless of the presence of + QCoreApplication::AA_ShareOpenGLContexts. \section1 Limitations |