aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language/evaluatorscriptclass.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-11-29 16:19:15 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2017-11-30 09:11:53 +0000
commit98d7cdd3c3e60efee26cfbe18b45d7506e0862e1 (patch)
tree4c103820a89aaf2e2ff35c7f422840d006596dbc /src/lib/corelib/language/evaluatorscriptclass.cpp
parent56c532b57a68eadf162da217e69da2779832cfc8 (diff)
Do type checks and conversions also for Probe properties
Due to the unusual the way the configure script sets the properties of the Probe item (i.e. not via a binding), we have to do the type conversion explicitly for these. Change-Id: If6a1dedabde4846de56c1fbd8eaf725035a66368 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/lib/corelib/language/evaluatorscriptclass.cpp')
-rw-r--r--src/lib/corelib/language/evaluatorscriptclass.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index 608d918f1..fbe06f389 100644
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -463,19 +463,13 @@ static void makeTypeError(const PropertyDeclaration &decl, const CodeLocation &l
makeTypeError(error, v);
}
-static void convertToPropertyType(const QString &pathPropertiesBaseDir, const Item *item,
- const PropertyDeclaration& decl,
- const Value *value, QScriptValue &v)
+static void convertToPropertyType_impl(const QString &pathPropertiesBaseDir, const Item *item,
+ const PropertyDeclaration& decl,
+ const CodeLocation &location, QScriptValue &v)
{
- if (value->type() == Value::VariantValueType && v.isUndefined() && !decl.isScalar()) {
- v = v.engine()->newArray(); // QTBUG-51237
- return;
- }
-
if (v.isUndefined() || v.isError())
return;
QString srcDir;
- const CodeLocation &location = value->location();
switch (decl.type()) {
case PropertyDeclaration::UnknownType:
case PropertyDeclaration::Variant:
@@ -494,7 +488,8 @@ static void convertToPropertyType(const QString &pathPropertiesBaseDir, const It
makeTypeError(decl, location, v);
break;
}
- const QString srcDir = overriddenSourceDirectory(item, pathPropertiesBaseDir);
+ const QString srcDir = item ? overriddenSourceDirectory(item, pathPropertiesBaseDir)
+ : pathPropertiesBaseDir;
if (!srcDir.isEmpty())
v = v.engine()->toScriptValue(QDir::cleanPath(
FileInfo::resolvePath(srcDir, v.toString())));
@@ -505,7 +500,8 @@ static void convertToPropertyType(const QString &pathPropertiesBaseDir, const It
makeTypeError(decl, location, v);
break;
case PropertyDeclaration::PathList:
- srcDir = overriddenSourceDirectory(item, pathPropertiesBaseDir);
+ srcDir = item ? overriddenSourceDirectory(item, pathPropertiesBaseDir)
+ : pathPropertiesBaseDir;
// Fall-through.
case PropertyDeclaration::StringList:
{
@@ -546,6 +542,22 @@ static void convertToPropertyType(const QString &pathPropertiesBaseDir, const It
}
}
+void EvaluatorScriptClass::convertToPropertyType(const PropertyDeclaration &decl,
+ const CodeLocation &loc, QScriptValue &v)
+{
+ convertToPropertyType_impl(QString(), nullptr, decl, loc, v);
+}
+
+void EvaluatorScriptClass::convertToPropertyType(const Item *item, const PropertyDeclaration& decl,
+ const Value *value, QScriptValue &v)
+{
+ if (value->type() == Value::VariantValueType && v.isUndefined() && !decl.isScalar()) {
+ v = v.engine()->newArray(); // QTBUG-51237
+ return;
+ }
+ convertToPropertyType_impl(m_pathPropertiesBaseDir, item, decl, value->location(), v);
+}
+
class PropertyStackManager
{
public:
@@ -631,7 +643,7 @@ QScriptValue EvaluatorScriptClass::property(const QScriptValue &object, const QS
converter.start();
const PropertyDeclaration decl = data->item->propertyDeclaration(name.toString());
- convertToPropertyType(m_pathPropertiesBaseDir, data->item, decl, value.get(), result);
+ convertToPropertyType(data->item, decl, value.get(), result);
}
if (debugProperties)