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

SignalSpy's clear() function is incorrectly documented as causing valid to become false

XMLWordPrintable

    • aaaa7a063 (dev), 28bcc7ca9 (6.10), 2cbea6584 (6.9)

      http://doc.qt.io/qt-5/qml-qttest-signalspy.html#clear-method says:

      Clears count to 0, resets valid to false and clears the signalArguments to empty.

      However, the following code works fine:

      import QtQuick 2.0
      import QtTest 1.0
      
      TestCase {
          name: "Untitled"
      
          Item {
              id: item
      
              signal test
          }
      
          SignalSpy {
              id: spy
          }
      
          function test_tryVerify() {
              spy.target = item;
              spy.signalName = "test";
              item.test();
              compare(spy.count, 1)
      
              spy.clear();
              compare(spy.count, 0);
              compare(spy.signalArguments.length, 0);
              verify(spy.valid);
              print(spy.target, spy.signalName)
      
              item.test();
              compare(spy.count, 1)
          }
      }
      

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

            docteam Qt Documentation Team
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes