diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-03-07 10:20:19 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-23 17:02:09 +0200 |
commit | 21aa22ba3fe2f6424742ba0a8fbf39937b81ad13 (patch) | |
tree | 5d24cf8b5b971286036f1e7f24e2f078dc77d79c /examples/quick/scenegraph/textureinthread/main.cpp | |
parent | a028d463508ed0612f7fd1d2b1365c5c091dc1b4 (diff) |
Create BG context and fake surface on GUI thread
This makes the example more messy and also makes it very hard
to avoid the initial black frame, but it is not compliant with
the limitations we experience on Windows.
Task-number: QTBUG-30077
Change-Id: If5a6da16f8fc1269cd20d2aa1190588025203d4f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'examples/quick/scenegraph/textureinthread/main.cpp')
-rw-r--r-- | examples/quick/scenegraph/textureinthread/main.cpp | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/examples/quick/scenegraph/textureinthread/main.cpp b/examples/quick/scenegraph/textureinthread/main.cpp index e415d254a1..3286055496 100644 --- a/examples/quick/scenegraph/textureinthread/main.cpp +++ b/examples/quick/scenegraph/textureinthread/main.cpp @@ -38,6 +38,8 @@ ** ****************************************************************************/ +#include <QtCore/QThread> + #include <QGuiApplication> #include <QtQuick/QQuickView> @@ -49,11 +51,31 @@ int main(int argc, char **argv) QGuiApplication app(argc, argv); qmlRegisterType<ThreadRenderer>("SceneGraphRendering", 1, 0, "Renderer"); + int execReturn = 0; + + { + QQuickView view; + + // Rendering in a thread introduces a slightly more complicated cleanup + // so we ensure that no cleanup of graphics resources happen until the + // application is shutting down. + view.setPersistentOpenGLContext(true); + view.setPersistentSceneGraph(true); + + view.setResizeMode(QQuickView::SizeRootObjectToView); + view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml")); + view.show(); + + execReturn = app.exec(); + } - QQuickView view; - view.setResizeMode(QQuickView::SizeRootObjectToView); - view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml")); - view.show(); + // As the render threads make use of our QGuiApplication object + // to clean up gracefully, wait for them to finish before + // QGuiApp is taken off the heap. + foreach (QThread *t, ThreadRenderer::threads) { + t->wait(); + delete t; + } - return app.exec(); + return execReturn; } |