From 21aa22ba3fe2f6424742ba0a8fbf39937b81ad13 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 7 Mar 2013 10:20:19 +0100 Subject: Create BG context and fake surface on GUI thread MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Samuel Rødal --- examples/quick/scenegraph/textureinthread/main.cpp | 32 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'examples/quick/scenegraph/textureinthread/main.cpp') 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 + #include #include @@ -49,11 +51,31 @@ int main(int argc, char **argv) QGuiApplication app(argc, argv); qmlRegisterType("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; } -- cgit v1.2.3