Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-48963

QMetaProperty writes a null string instead of empty string

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 5.4.2, 5.5.1
    • Core: Object Model
    • None

    Description

      QMetaProperty::write or QObject::setProperty writes null string instead of empty string (does nothing) to property when the initial value of the property is null string.

      I noticed it filling object properties through Q_PROPERTY with MEMBER attribute (works well with WRITE accessor and the assignment operator in the setter).

      Example
          X a, b;
          
          a.setProperty("value", "");
      
          b.setProperty("value", "abc");
          b.setProperty("value", "");
      
          qDebug() << a.property("value").isNull() << b.property("value").isNull();
      
      class X : public QObject { ... Q_PROPERTY(QString value MEMBER _value) ... }
      
      Output: true false
      
      class X : public QObject { ... Q_PROPERTY(QString value READ value WRITE setValue) ...
          void setValue(const QString &value) { _value = value; } ... }
      
      Output: false false
      

      There is no problem with the dynamic properties.

      QObject o;
      o.setProperty("dynamic", ""); // o.property("dynamic").isNull() = false
      o.setProperty("dynamic", "abc"); // o.property("dynamic").isNull() = false
      o.setProperty("dynamic", QString()); // o.property("dynamic").isNull() = true
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            starlight starlight
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes