Merge branch 'newdocs'
[profile/ivi/qtdeclarative.git] / examples / shared / shared.h
index 613798f..e725f81 100644 (file)
@@ -39,6 +39,7 @@
 ****************************************************************************/
 #include <QDir>
 #include <QGuiApplication>
+#include <QQmlEngine>
 #include <QQuickView>
 #define DECLARATIVE_EXAMPLE_MAIN(NAME) int main(int argc, char* argv[]) \
 {\
     if (QGuiApplication::platformName() == QLatin1String("windows")) {\
         if (directory.absolutePath().endsWith("/debug", Qt::CaseInsensitive)\
             || directory.absolutePath().endsWith("/release", Qt::CaseInsensitive))\
-            if (!directory.cdUp())\
-                exit(-1);\
-    } else if (QGuiApplication::platformName() == QLatin1String("Cocoa")) {\
+            if (!directory.cdUp()) {\
+                qWarning("Could not change to parent directory of '%s'",\
+                    qPrintable(QDir::toNativeSeparators(directory.absolutePath())));\
+                return -1;\
+            }\
+    } else if (QGuiApplication::platformName() == QLatin1String("cocoa")) {\
         if (directory.absolutePath().endsWith(#NAME".app/Contents/MacOS"))\
             for (int i = 0; i < 3; ++i) {\
-                if (!directory.cdUp())\
-                    exit(-1);\
+                if (!directory.cdUp()) {\
+                    qWarning("Could not change to parent directory of '%s'",\
+                        qPrintable(QDir::toNativeSeparators(directory.absolutePath())));\
+                    return -1;\
+                }\
             }\
     }\
     const QString fileName(directory.absolutePath() + "/" #NAME ".qml");\
-    if (!QFile::exists(fileName))\
-            exit(-1);\
+    if (!QFile::exists(fileName)) {\
+            qWarning("Could not find file '%s'", qPrintable(QDir::toNativeSeparators(fileName)));\
+            return -1;\
+    }\
+    view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));\
     view.setSource(QUrl::fromLocalFile(fileName));\
     view.show();\
     return app.exec();\