macdeployqt: Work around broken QLibraryInfo
authorMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
Wed, 12 Aug 2015 11:54:31 +0000 (13:54 +0200)
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
Thu, 13 Aug 2015 10:14:02 +0000 (10:14 +0000)
Add fallback code path for locating qmlimportscanner
relative to the macdeployqt binary.

Task-number: QTBUG-46404
Change-Id: I9c837b5da518af45cef1292f9cd0422fccba8e5f
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
src/macdeployqt/macdeployqt/main.cpp
src/macdeployqt/shared/shared.cpp

index 9c6e3fe..3cc8f5a 100644 (file)
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+#include <QCoreApplication>
+#include <QDir>
+
 #include "../shared/shared.h"
-#include <qdir.h>
 
 int main(int argc, char **argv)
 {
+    QCoreApplication app(argc, argv);
+
     QString appBundlePath;
     if (argc > 1)
         appBundlePath = QString::fromLocal8Bit(argv[1]);
index 0cc5963..d20b219 100644 (file)
@@ -30,6 +30,7 @@
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
+#include <QCoreApplication>
 #include <QString>
 #include <QStringList>
 #include <QDebug>
@@ -1079,8 +1080,14 @@ bool deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
     LogNormal() << "Deploying QML imports ";
     LogNormal() << "Application QML file search path(s) is" << qmlDirs;
 
-    // verify that qmlimportscanner is in BinariesPath
+    // Use qmlimportscanner from QLibraryInfo::BinariesPath
     QString qmlImportScannerPath = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlimportscanner");
+
+    // Fallback: Look relative to the macdeployqt binary
+    if (!QFile(qmlImportScannerPath).exists())
+        qmlImportScannerPath = QCoreApplication::applicationDirPath() + "/qmlimportscanner";
+
+    // Verify that we found a qmlimportscanner binary
     if (!QFile(qmlImportScannerPath).exists()) {
         LogError() << "qmlimportscanner not found at" << qmlImportScannerPath;
         LogError() << "Rebuild qtdeclarative/tools/qmlimportscanner";