From f2acb103678791a92d259cf8f743c9edbc038816 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@digia.com>
Date: Mon, 1 Sep 2014 13:58:13 +0200
Subject: [PATCH] windeployqt: Special case non-standard modules.

Task-number: QTBUG-40670
Change-Id: I3897b4149587cf4e90cbdaf6d54ef8cff70d22d2
Reviewed-by: Andrew Knight <andrew.knight@digia.com>
---
 src/windeployqt/main.cpp | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp
index eacb236ad..be450dbd7 100644
--- a/src/windeployqt/main.cpp
+++ b/src/windeployqt/main.cpp
@@ -579,6 +579,13 @@ static inline QString helpText(const QCommandLineParser &p)
     return result;
 }
 
+static inline bool isQtModule(const QString &libName)
+{
+    return libName.startsWith(QLatin1String("Qt"), Qt::CaseInsensitive) // Standard modules, Qt5XX.dll, Qt[Commercial]Charts.dll
+        || libName.startsWith(QLatin1String("DataVisualization"), Qt::CaseInsensitive)
+        || libName.startsWith(QLatin1String("Enginio"), Qt::CaseInsensitive);
+}
+
 // Helper for recursively finding all dependent Qt libraries.
 static bool findDependentQtLibraries(const QString &qtBinDir, const QString &binary, Platform platform,
                                      QString *errorMessage, QStringList *result,
@@ -596,11 +603,12 @@ static bool findDependentQtLibraries(const QString &qtBinDir, const QString &bin
     // Filter out the Qt libraries. Note that depends.exe finds libs from optDirectory if we
     // are run the 2nd time (updating). We want to check against the Qt bin dir libraries
     const int start = result->size();
-    const QRegExp filterRegExp(QStringLiteral("Qt5"), Qt::CaseInsensitive, QRegExp::FixedString);
-    foreach (const QString &qtLib, dependentLibs.filter(filterRegExp)) {
-        const QString path = normalizeFileName(qtBinDir + QLatin1Char('/') + QFileInfo(qtLib).fileName());
-        if (!result->contains(path))
-            result->append(path);
+    foreach (const QString &lib, dependentLibs) {
+        if (isQtModule(lib)) {
+            const QString path = normalizeFileName(qtBinDir + QLatin1Char('/') + QFileInfo(lib).fileName());
+            if (!result->contains(path))
+                result->append(path);
+        }
     }
     const int end = result->size();
     if (directDependencyCount)
-- 
GitLab