aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2016-10-10 17:44:19 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2016-10-14 14:42:07 +0000
commit47b575a3b3bf7dc104e1b91babc986577a63ff37 (patch)
treee6fedd69fab4011a29a32f3cc912fa52d51c1a60
parent1e60fab274e722efa01bce67c9acc56627fcc801 (diff)
Convert null variant values to empty lists
... if their declared type is a list. This is a workaround for QTBUG-51237. Change-Id: Ie9e02f5fd125ce73b993e59af0e3dc2b47fe14c1 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
-rw-r--r--src/lib/corelib/language/evaluatorscriptclass.cpp10
-rw-r--r--src/lib/corelib/language/projectresolver.cpp7
-rw-r--r--tests/auto/blackbox/testdata/QTBUG-51237/modules/mymodule/mymodule.qbs6
-rw-r--r--tests/auto/blackbox/testdata/QTBUG-51237/qtbug-51237.qbs22
-rw-r--r--tests/auto/blackbox/tst_blackbox.cpp20
-rw-r--r--tests/auto/blackbox/tst_blackbox.h1
6 files changed, 63 insertions, 3 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index 8230d3990..aa07935dc 100644
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -398,8 +398,14 @@ static QString overriddenSourceDirectory(const Item *item)
}
inline void convertToPropertyType(const Item *item, const PropertyDeclaration::Type t,
- QScriptValue &v)
+ Value::Type valueType, QScriptValue &v)
{
+ if (valueType == Value::VariantValueType && v.isUndefined()
+ && (t == PropertyDeclaration::StringList || t == PropertyDeclaration::PathList)) {
+ v = v.engine()->newArray(); // QTBUG-51237
+ return;
+ }
+
if (v.isUndefined() || v.isError())
return;
switch (t) {
@@ -497,7 +503,7 @@ QScriptValue EvaluatorScriptClass::property(const QScriptValue &object, const QS
converter.start();
const PropertyDeclaration decl = data->item->propertyDeclaration(name.toString());
- convertToPropertyType(data->item, decl.type(), result);
+ convertToPropertyType(data->item, decl.type(), value->type(), result);
}
if (debugProperties)
diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp
index e712aff49..bfb2eb74c 100644
--- a/src/lib/corelib/language/projectresolver.cpp
+++ b/src/lib/corelib/language/projectresolver.cpp
@@ -1129,7 +1129,12 @@ QVariantMap ProjectResolver::evaluateProperties(Item *item, Item *propertiesCont
if (result.contains(it.key()))
break;
VariantValuePtr vvp = it.value().staticCast<VariantValue>();
- result[it.key()] = vvp->value();
+ QVariant v = vvp->value();
+
+ if (v.isNull() && !item->propertyDeclaration(it.key()).isScalar()) // QTBUG-51237
+ v = QStringList();
+
+ result[it.key()] = v;
break;
}
}
diff --git a/tests/auto/blackbox/testdata/QTBUG-51237/modules/mymodule/mymodule.qbs b/tests/auto/blackbox/testdata/QTBUG-51237/modules/mymodule/mymodule.qbs
new file mode 100644
index 000000000..223da0b3c
--- /dev/null
+++ b/tests/auto/blackbox/testdata/QTBUG-51237/modules/mymodule/mymodule.qbs
@@ -0,0 +1,6 @@
+import qbs
+
+Module {
+ property stringList theProperty: []
+ //property stringList otherProperty: theProperty.concat([])
+}
diff --git a/tests/auto/blackbox/testdata/QTBUG-51237/qtbug-51237.qbs b/tests/auto/blackbox/testdata/QTBUG-51237/qtbug-51237.qbs
new file mode 100644
index 000000000..e1f8d8ef6
--- /dev/null
+++ b/tests/auto/blackbox/testdata/QTBUG-51237/qtbug-51237.qbs
@@ -0,0 +1,22 @@
+import qbs
+
+Product {
+ type: "custom"
+ Depends { name: "mymodule" }
+ Rule {
+ multiplex: true
+ Artifact {
+ filePath: "dummy.custom"
+ fileTags: ["custom"]
+ }
+ prepare: {
+ var theProperty = product.moduleProperty("mymodule", "theProperty");
+ if (!theProperty)
+ throw "Oh no!";
+ var dummy = new JavaScriptCommand();
+ dummy.silent = true;
+ dummy.sourceCode = function() {};
+ return [dummy];
+ }
+ }
+}
diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp
index 80c3a1f1c..74329abf2 100644
--- a/tests/auto/blackbox/tst_blackbox.cpp
+++ b/tests/auto/blackbox/tst_blackbox.cpp
@@ -2335,6 +2335,26 @@ void TestBlackbox::qobjectInObjectiveCpp()
QCOMPARE(runQbs(), 0);
}
+void TestBlackbox::qtBug51237()
+{
+ const QString profileName = "profile-qtBug51237";
+ const QString propertyName = "mymodule.theProperty";
+ {
+ Settings settings((QString()));
+ Profile profile(profileName, &settings);
+ profile.setValue(propertyName, QStringList());
+ }
+ Settings settings((QString()));
+ qbs::Internal::TemporaryProfile profile(profileName, &settings);
+ const QVariant propertyValue = profile.p.value(propertyName);
+ QVERIFY(!propertyValue.isValid()); // QTBUG-51237
+ QDir::setCurrent(testDataDir + "/QTBUG-51237");
+ QbsRunParameters params;
+ params.arguments << "profile:" + profileName;
+ params.useProfile = false;
+ QCOMPARE(runQbs(params), 0);
+}
+
void TestBlackbox::dynamicMultiplexRule()
{
const QString testDir = testDataDir + "/dynamicMultiplexRule";
diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h
index 64e3b0770..b5a539bb8 100644
--- a/tests/auto/blackbox/tst_blackbox.h
+++ b/tests/auto/blackbox/tst_blackbox.h
@@ -199,6 +199,7 @@ private slots:
void qbsVersion();
void qmlDebugging();
void qobjectInObjectiveCpp();
+ void qtBug51237();
void radAfterIncompleteBuild_data();
void radAfterIncompleteBuild();
void recursiveRenaming();