diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index ddcd259ae04c8f838bf15230a5f18d4f5c7c0216..804241f0232c7269826b7e6e357b2d64b60fa7f9 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -72,8 +72,11 @@
 #define VERSION_MIN 0
 #define VERSION_STR "1.0"
 
+#define FILE_OPEN_EVENT_WAIT_TIME 3000 // ms
+
 static Config *conf = 0;
 static QQmlApplicationEngine *qae = 0;
+static int exitTimerId = -1;
 
 static void loadConf(const QString &override, bool quiet) // Terminates app on failure
 {
@@ -138,6 +141,8 @@ void contain(QObject *o, const QUrl &containPath)
 
 #ifdef QT_GUI_LIB
 
+void noFilesGiven();
+
 // Loads qml after receiving a QFileOpenEvent
 class LoaderApplication : public QGuiApplication
 {
@@ -146,12 +151,21 @@ public:
 
     bool event(QEvent *ev)
     {
-        if (ev->type() == QEvent::FileOpen)
+        if (ev->type() == QEvent::FileOpen) {
+            if (exitTimerId >= 0) {
+                killTimer(exitTimerId);
+                exitTimerId = -1;
+            }
             qae->load(static_cast<QFileOpenEvent *>(ev)->url());
+        }
         else
             return QGuiApplication::event(ev);
         return true;
     }
+
+    void timerEvent(QTimerEvent *) {
+        noFilesGiven();
+    }
 };
 
 #endif // QT_GUI_LIB
@@ -274,6 +288,13 @@ void printUsage()
     exit(0);
 }
 
+void noFilesGiven()
+{
+    if (!quietMode)
+        printf("qml: No files specified. Terminating.\n");
+    exit(1);
+}
+
 //Called before application initialization, removes arguments it uses
 void getAppFlags(int &argc, char **argv)
 {
@@ -462,9 +483,12 @@ int main(int argc, char *argv[])
         qInstallMessageHandler(quietMessageHandler);
 
     if (files.count() <= 0) {
-        if (!quietMode)
-            printf("qml: No files specified. Terminating.\n");
-        exit(1);
+#if defined(Q_OS_MAC)
+        if (applicationType == QmlApplicationTypeGui)
+            exitTimerId = static_cast<LoaderApplication *>(app)->startTimer(FILE_OPEN_EVENT_WAIT_TIME);
+        else
+#endif
+        noFilesGiven();
     }
 
     qae = &e;