macdeployqt: Workaround for QtQuick.PrivateWidgets
authorMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
Tue, 11 Aug 2015 14:19:24 +0000 (16:19 +0200)
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
Thu, 13 Aug 2015 09:03:48 +0000 (09:03 +0000)
Deploy PrivateWidgets if QtWidget.framework and
QtQuick.Controls is in use.

Task-number: QTBUG-45977
Change-Id: Id2d7af8895be136d84bed92043fc790b156d8dea
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
src/macdeployqt/shared/shared.cpp

index b85fa0d..d6dcfb6 100644 (file)
@@ -1108,6 +1108,8 @@ void deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
         return;
     }
 
+    bool qtQuickContolsInUse = false; // condition for QtQuick.PrivateWidgets below
+
     // deploy each import
     foreach (const QJsonValue &importValue, doc.array()) {
         if (!importValue.isObject())
@@ -1118,6 +1120,9 @@ void deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
         QString path = import["path"].toString();
         QString type = import["type"].toString();
 
+        if (import["name"] == "QtQuick.Controls")
+            qtQuickContolsInUse = true;
+
         LogNormal() << "Deploying QML import" << name;
 
         // Skip imports with missing info - path will be empty if the import is not found.
@@ -1147,6 +1152,21 @@ void deployQmlImports(const QString &appBundlePath, DeploymentInfo deploymentInf
         deployQmlImport(appBundlePath, deploymentInfo.rpathsUsed, path, name);
         LogNormal() << "";
     }
+
+    // Special case:
+    // Use of QtQuick.PrivateWidgets is not discoverable at deploy-time.
+    // Recreate the run-time logic here as best as we can - deploy it iff
+    //      1) QtWidgets.framework is used
+    //      2) QtQuick.Controls is used
+    // The intended failure mode is that libwidgetsplugin.dylib will be present
+    // in the app bundle but not used at run-time.
+    if (deploymentInfo.deployedFrameworks.contains("QtWidgets.framework") && qtQuickContolsInUse) {
+        LogNormal() << "Deploying QML import QtQuick.PrivateWidgets";
+        QString name = "QtQuick/PrivateWidgets";
+        QString path = qmlImportsPath + QLatin1Char('/') + name;
+        deployQmlImport(appBundlePath, deploymentInfo.rpathsUsed, path, name);
+        LogNormal() << "";
+    }
 }
 
 void changeQtFrameworks(const QList<FrameworkInfo> frameworks, const QStringList &binaryPaths, const QString &absoluteQtPath)