diff options
Diffstat (limited to 'src/webchannel')
-rw-r--r-- | src/webchannel/qmetaobjectpublisher.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp index c956676..e641109 100644 --- a/src/webchannel/qmetaobjectpublisher.cpp +++ b/src/webchannel/qmetaobjectpublisher.cpp @@ -793,16 +793,16 @@ QVariant QMetaObjectPublisher::toVariant(const QJsonValue &value, int targetType return QVariant(target, reinterpret_cast<const void*>(&flagsValue)); } - QVariant variant = QJsonValue::fromVariant(value); - // Try explicit conversion to the target type first. If that fails, fall - // back to generic conversion + QVariant variant = value.toVariant(); + // Try variant conversion to the target type first. If that fails, + // try conversion over QJsonvalue. if (auto converted = variant; converted.convert(target)) { variant = std::move(converted); - } else { - if (targetType != QMetaType::QVariant) { + } else if (targetType != QMetaType::QVariant) { + if (QVariant converted = value; converted.convert(target)) + variant = std::move(converted); + else qWarning() << "Could not convert argument" << value << "to target type" << target.name() << '.'; - } - variant = value.toVariant(); } return unwrapVariant(variant); } |