Disable textureinthread example when threaded gl is not available.
authorGunnar Sletta <gunnar.sletta@digia.com>
Wed, 22 May 2013 08:35:27 +0000 (10:35 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 22 May 2013 10:39:38 +0000 (12:39 +0200)
Task-number: QTBUG-30077
Change-Id: I8b6e4b8a33819fe84c843e85d863b582cfd69439
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
examples/quick/scenegraph/textureinthread/error.qml [new file with mode: 0644]
examples/quick/scenegraph/textureinthread/main.cpp
examples/quick/scenegraph/textureinthread/textureinthread.pro
examples/quick/scenegraph/textureinthread/textureinthread.qrc

diff --git a/examples/quick/scenegraph/textureinthread/error.qml b/examples/quick/scenegraph/textureinthread/error.qml
new file mode 100644 (file)
index 0000000..1dbd576
--- /dev/null
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+**   * Redistributions of source code must retain the above copyright
+**     notice, this list of conditions and the following disclaimer.
+**   * Redistributions in binary form must reproduce the above copyright
+**     notice, this list of conditions and the following disclaimer in
+**     the documentation and/or other materials provided with the
+**     distribution.
+**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+**     of its contributors may be used to endorse or promote products derived
+**     from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Text {
+    width: 400
+    height: 100
+    text: 'Platform does not support threaded OpenGL needed by this example.'
+    verticalAlignment: Text.AlignVCenter
+    horizontalAlignment: Text.AlignHCenter
+}
index 3286055..801f189 100644 (file)
@@ -42,6 +42,9 @@
 
 #include <QGuiApplication>
 
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformintegration.h>
+
 #include <QtQuick/QQuickView>
 
 #include "threadrenderer.h"
@@ -50,6 +53,13 @@ int main(int argc, char **argv)
 {
     QGuiApplication app(argc, argv);
 
+    if (!QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::ThreadedOpenGL)) {
+        QQuickView view;
+        view.setSource(QUrl("qrc:///scenegraph/textureinthread/error.qml"));
+        view.show();
+        return app.exec();
+    }
+
     qmlRegisterType<ThreadRenderer>("SceneGraphRendering", 1, 0, "Renderer");
     int execReturn = 0;
 
@@ -63,7 +73,7 @@ int main(int argc, char **argv)
         view.setPersistentSceneGraph(true);
 
         view.setResizeMode(QQuickView::SizeRootObjectToView);
-        view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml"));
+        view.setSource(QUrl("qrc:///scenegraph/textureinthread/main.qml"));
         view.show();
 
         execReturn = app.exec();
index b48c2a1..7f5fbb7 100644 (file)
@@ -1,5 +1,8 @@
 QT += quick
 
+# To make threaded gl check...
+QT += core-private gui-private
+
 HEADERS += threadrenderer.h
 SOURCES += threadrenderer.cpp main.cpp
 
@@ -13,4 +16,5 @@ target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/textureinthread
 INSTALLS += target
 
 OTHER_FILES += \
-    main.qml
+    main.qml \
+    error.qml
index 9ecf0ad..66eb53b 100644 (file)
@@ -1,5 +1,6 @@
 <RCC>
-    <qresource prefix="/scenegraph/textureinsgnode">
+    <qresource prefix="/scenegraph/textureinthread">
         <file>main.qml</file>
+        <file>error.qml</file>
     </qresource>
 </RCC>