Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.8.0
-
None
-
d61c0ce1b (dev), 373cf5eae (dev), 11c6eff62 (6.8), b497a4391 (6.8)
Description
Consider:
class VARIANT { Q_GADGET QML_VALUE_TYPE(variant) QML_CONSTRUCTIBLE_VALUE Q_PROPERTY(QDBusVariant value READ getValue) public: explicit VARIANT() { } Q_INVOKABLE explicit VARIANT(const QJSValue &_value) : value(_value.toVariant()) { qDebug() << Q_FUNC_INFO << value.variant() << _value.toString(); } operator QVariant() const { return value.variant(); } operator QDBusVariant() const { return value; } Q_INVOKABLE QString toString() const { return value.variant().toString(); } QDBusVariant getValue() const { return value; } QDBusVariant value; constexpr static const char *signature = "v"; };
Now assign to such a thing in QML:
import QtQml import varianttype as DBus QtObject { property DBus.variant test: "abcdefg" }
With versions prior to 6.8 this is just refused:
Could not find any constructor for value type VARIANT to call with value QVariant(QString, abcdefg)
QQmlApplicationEngine failed to create component
qrc:/qt/qml/varianttype/Main.qml:5:27: Cannot assign value abcdefg to property test
With 6.8 and later, the constructor is called, but with an "undefined" QJSValue. That's even worse.
Attachments
Issue Links
- split from
-
QTBUG-125341 QML_CONSTRUCTIBLE_VALUE has a strange strategy to select the right constructor
- Closed
For Gerrit Dashboard: QTBUG-130522 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
599598,4 | QtQml: Only pass matching arguments to value type constructors | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
599599,4 | QtQml: Support conversion to QJSValue when constructing value types | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
601231,2 | QtQml: Only pass matching arguments to value type constructors | 6.8 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
601234,3 | QtQml: Support conversion to QJSValue when constructing value types | 6.8 | qt/qtdeclarative | Status: MERGED | +2 | 0 |