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

signal of dynamic-property imported by QQmlPropertyMap will always be emitted by qml component whenever property has changed



    • 16b680b734101db0cb4fa3f313ac563a509ddff4


      The problem was found since i import qml with dynamic-property, maybe in version 5.2 or 5.3, but still exists in the latest version 5.5.
      Following is my c++ code:
      QQmlPropertyMap* map = new QQmlPropertyMap;
      map->insert("abc", false);

      QQmlApplicationEngine engine;
      engine.rootContext()->setContextProperty("myObject", map);
      and then, the qml code:
      Connections {
      target: myObject

      {console.log("abc changed! ", myObject.abc)}



      { myObject.abc = true; console.log("mouse clicked!") }

      last, the result in console:
      qml: abc changed! true
      qml: mouse clicked!
      qml: abc changed! true
      qml: mouse clicked!
      qml: abc changed! true
      qml: mouse clicked!

      For this problem, i read the Qt's source code, and catched a probable reason. i corrected the error logic in souce code ,and recompiled it, achived a fixed version of QtQmld.dll. With the fixed version, my problem had been resolved.

      Following is the source code:
      file-> src/qtdeclarative/src/qml/qml/qqmlopenmetaobject.cpp
      function-> metaCall, line->242
      241 else if (c == QMetaObject::WriteProperty) {
      242 if (propId <= d->data.count() || d->data[propId].first != *reinterpret_cast<QVariant *>(a[0]))

      { 243 propertyWrite(propId); ... ... 249 }

      In line 242, the propId of existed property will always be lower than d->data.count(), so the property will always be written and signal will be emitted.

      I modified "<=" to be ">=", and then, for existed property, value comparison will be done, and signal will not be emitted by qml-same-value. for new-added property, its propId will be larger than or equals with data.count(), value will be written and signal will be emitted.


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



            tmcguire Thomas McGuire
            tyhj cstyhj
            0 Vote for this issue
            2 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes