aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2016-10-25 20:56:40 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2016-10-25 20:56:40 +0200
commitd56d0baefd53a8c7f3a9cd10fcaaeef1826e7d06 (patch)
tree7d03728d1c011a2d3a35fb8cf183caee9c4160fc
parenteb6e5b591ec3972dad11656fff6bfa0597483c4c (diff)
downloadqmenumodel-d56d0baefd53a8c7f3a9cd10fcaaeef1826e7d06.tar.gz
qmenumodel-d56d0baefd53a8c7f3a9cd10fcaaeef1826e7d06.tar.bz2
qmenumodel-d56d0baefd53a8c7f3a9cd10fcaaeef1826e7d06.zip
converter: return a variant when the schema is a variant
-rw-r--r--libqmenumodel/src/converter.cpp2
-rw-r--r--tests/client/convertertest.cpp5
2 files changed, 6 insertions, 1 deletions
diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp
index cbf8076..ff70803 100644
--- a/libqmenumodel/src/converter.cpp
+++ b/libqmenumodel/src/converter.cpp
@@ -315,7 +315,7 @@ GVariant* Converter::toGVariantWithSchema(const QVariant &value, const char* sch
result = g_variant_new_string(qUtf8Printable(value.toString()));
}
} else if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_VARIANT)) {
- result = Converter::toGVariant(value);
+ result = g_variant_new_variant(Converter::toGVariant(value));
} else if (g_variant_type_equal(schema_type, G_VARIANT_TYPE_VARDICT)) {
if (value.canConvert(QVariant::Map)) {
result = Converter::toGVariant(value.toMap());
diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp
index f1fd48e..5492a02 100644
--- a/tests/client/convertertest.cpp
+++ b/tests/client/convertertest.cpp
@@ -192,6 +192,11 @@ private Q_SLOTS:
QTest::newRow("int64") << QVariant::fromValue<int>(1) << "x";
QTest::newRow("uint64") << QVariant::fromValue<int>(1) << "t";
+ // convert to variant
+ QTest::newRow("variant from int") << QVariant::fromValue<int>(1) << "v";
+ QTest::newRow("variant from double") << QVariant::fromValue<double>(1.1) << "v";
+ QTest::newRow("variant from string") << QVariant::fromValue<QString>("string") << "v";
+
// convert to bool
QTest::newRow("bool") << QVariant::fromValue<bool>(true) << "b";
QTest::newRow("bool from int") << QVariant::fromValue<int>(1) << "b";