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

Setting Connections.target to null not always disconnects the target

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.6.3
    • 5.7.0
    • None
    • Linux yoga 4.7.6-1-ARCH #1 SMP PREEMPT Fri Sep 30 19:28:42 CEST 2016 x86_64 GNU/Linux

    Description

      I.e. it does not work when `target` was set to the parent item via the default behaviour.

      Per the documentation, setting `target` to `null` should disconnect the Connection: http://doc.qt.io/qt-5/qml-qtqml-connections.html#target-prop.

      If set to null, no connection is made and any signal handlers are ignored until the target is not null.

      Testcase:

      test.qml
      import QtQuick 2.0
      
      Item {
          MouseArea {
              id: mouse_area
              anchors.fill: parent
              Connections {
                  id: connections
                  // target: mouse_area // Testcase works if this line is uncommented
                  onPressedChanged: {
                      console.log("pressed changed")
                  }
              }
              onClicked: {
                  console.log("connections target", connections.target, mouse_area)
                  connections.target = null
                  console.log("connections target", connections.target, mouse_area)
              }
          }
      }
      

      Refs: https://github.com/qmlweb/qmlweb/pull/344

      Attachments

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

        Activity

          People

            mbrasser Michael Brasser
            chalker Сковорода Никита
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes