summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/script/bridge/qscriptvariant.cpp2
-rw-r--r--tests/auto/qscriptvalue/tst_qscriptvalue.cpp2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/script/bridge/qscriptvariant.cpp b/src/script/bridge/qscriptvariant.cpp
index c4a152a..ab75a02 100644
--- a/src/script/bridge/qscriptvariant.cpp
+++ b/src/script/bridge/qscriptvariant.cpp
@@ -137,7 +137,7 @@ static JSC::JSValue JSC_HOST_CALL variantProtoFuncToString(JSC::ExecState *exec,
JSC::JSValue value = variantProtoFuncValueOf(exec, callee, thisValue, args);
if (value.isObject()) {
result = v.toString();
- if (result.isEmpty()) {
+ if (result.isEmpty() && !v.canConvert(QVariant::String)) {
result = "QVariant(";
result += v.typeName();
result += ")";
diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
index f9ce79f..1c09693 100644
--- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
+++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp
@@ -447,6 +447,8 @@ void tst_QScriptValue::toString()
variant = eng.newVariant(QVariant(QPoint(10, 20)));
QVERIFY(variant.isVariant());
QCOMPARE(variant.toString(), QString::fromLatin1("QVariant(QPoint)"));
+ variant = eng.newVariant(QUrl());
+ QVERIFY(variant.toString().isEmpty());
}
void tst_QScriptValue::toNumber()