diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2024-03-05 12:28:58 +0300 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2024-03-05 14:44:05 +0000 |
commit | 44d658cbf479a597ba22bb661c8ca68d7a98be6d (patch) | |
tree | bb6262b0ceec271635163b282773694d1f9a5222 | |
parent | 75aca0dca12c6c94109e65ee035b6b533b33a3c5 (diff) |
Fix PathLists in Probes
Fixes: QBS-1785
Change-Id: I59e86d9caf80ac1e8870d53d0a91cb88ad0d35b5
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | src/lib/corelib/loader/probesresolver.cpp | 10 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/path-list-in-probe/main.cpp | 4 | ||||
-rw-r--r-- | tests/auto/blackbox/testdata/path-list-in-probe/path-list-in-probe.qbs | 18 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 6 | ||||
-rw-r--r-- | tests/auto/blackbox/tst_blackbox.h | 1 |
5 files changed, 35 insertions, 4 deletions
diff --git a/src/lib/corelib/loader/probesresolver.cpp b/src/lib/corelib/loader/probesresolver.cpp index efca2854c..269e9c4b6 100644 --- a/src/lib/corelib/loader/probesresolver.cpp +++ b/src/lib/corelib/loader/probesresolver.cpp @@ -198,10 +198,12 @@ void ProbesResolver::resolveProbe(ProductContext &productContext, Item *parent, if (JsException ex = engine->checkAndClearException({})) throw ex.toErrorInfo(); newValue = getJsVariant(ctx, v); - // special case, string lists are represented as js arrays and and we don't type - // info when converting - if (decl.type() == PropertyDeclaration::StringList - && newValue.userType() == QMetaType::QVariantList) { + // Special case, string and path lists are represented as js arrays but we don't + // want to make them const as we do for object lists. Converting to QStringList + // allows to distinguish between these two cases in ScriptEngine::asJsValue + if (newValue.userType() == QMetaType::QVariantList + && (decl.type() == PropertyDeclaration::StringList + || decl.type() == PropertyDeclaration::PathList)) { #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) newValue.convert(QMetaType(QMetaType::QStringList)); #else diff --git a/tests/auto/blackbox/testdata/path-list-in-probe/main.cpp b/tests/auto/blackbox/testdata/path-list-in-probe/main.cpp new file mode 100644 index 000000000..5bc549337 --- /dev/null +++ b/tests/auto/blackbox/testdata/path-list-in-probe/main.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 0; +}
\ No newline at end of file diff --git a/tests/auto/blackbox/testdata/path-list-in-probe/path-list-in-probe.qbs b/tests/auto/blackbox/testdata/path-list-in-probe/path-list-in-probe.qbs new file mode 100644 index 000000000..3bf36367a --- /dev/null +++ b/tests/auto/blackbox/testdata/path-list-in-probe/path-list-in-probe.qbs @@ -0,0 +1,18 @@ +Project { + CppApplication { + Probe { + id: theProbe + property pathList result + configure: { + result = ["main.cpp"] + found = true + } + } + property pathList res: theProbe.found ? theProbe.result : [] + + Group { + name: "files" + files: res + } + } +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index cd611e76f..917d7436c 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -3190,6 +3190,12 @@ void TestBlackbox::pathProbe() QVERIFY2(m_qbsStderr.contains("Probe failed to find files"), m_qbsStderr); } +void TestBlackbox::pathListInProbe() +{ + QDir::setCurrent(testDataDir + "/path-list-in-probe"); + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::pchChangeTracking() { QDir::setCurrent(testDataDir + "/pch-change-tracking"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 701002620..5ba53ef52 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -232,6 +232,7 @@ private slots: void overrideProjectProperties(); void pathProbe_data(); void pathProbe(); + void pathListInProbe(); void pchChangeTracking(); void perGroupDefineInExportItem(); void pkgConfigProbe(); |