Be more verbose about error when using shared.h for examples
authorOliver Wolff <oliver.wolff@digia.com>
Thu, 4 Oct 2012 08:26:52 +0000 (10:26 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 4 Oct 2012 10:55:16 +0000 (12:55 +0200)
Instead of just aborting the program it should at least give a hint
about what actually went wrong.

Change-Id: I4019b3c026ba1777905f457562bdc77e5c05df4f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
examples/shared/shared.h

index 613798f..0e9395a 100644 (file)
     if (QGuiApplication::platformName() == QLatin1String("windows")) {\
         if (directory.absolutePath().endsWith("/debug", Qt::CaseInsensitive)\
             || directory.absolutePath().endsWith("/release", Qt::CaseInsensitive))\
-            if (!directory.cdUp())\
-                exit(-1);\
+            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.setSource(QUrl::fromLocalFile(fileName));\
     view.show();\
     return app.exec();\