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

MultiPointTouchArea signals have touchPoints arguments which conflict with touchPoints property

    XMLWordPrintable

Details

    • 2b6eb1a51 (dev), e31abbf87 (6.5)

    Description

      class Q_QUICK_PRIVATE_EXPORT QQuickMultiPointTouchArea : public QQuickItem
      {
          Q_OBJECT
          Q_DISABLE_COPY_MOVE(QQuickMultiPointTouchArea)
      
          Q_PROPERTY(QQmlListProperty<QQuickTouchPoint> touchPoints READ touchPoints)
      ...
      Q_SIGNALS:
          void pressed(const QList<QObject*> &touchPoints);
          void updated(const QList<QObject*> &touchPoints);
          void released(const QList<QObject*> &touchPoints);
          void canceled(const QList<QObject*> &touchPoints);
          void gestureStarted(QQuickGrabGestureEvent *gesture);
          void touchUpdated(const QList<QObject*> &touchPoints);
      ...
      

      It's always been that way, but it causes some confusion when you write a signal handler, as in some autotests:

          onPressed: { touchPointPressCount = touchPoints.length }
          onUpdated: { touchPointUpdateCount = touchPoints.length }
          onReleased: { touchPointReleaseCount = touchPoints.length }
          onTouchUpdated: {
              touchCount = touchPoints.length
              touchUpdatedHandled = true
          }
      
      agent:2023/02/02 21:49:28 build.go:403: 160: QWARN  : tst_QQuickMultiPointTouchArea::signalTest() qt.qml.context: file:///home/qt/work/qt/qtdeclarative/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml:23:5 Parameter "touchPoints" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
      agent:2023/02/02 21:49:28 build.go:403: 160: QWARN  : tst_QQuickMultiPointTouchArea::signalTest() qt.qml.context: file:///home/qt/work/qt/qtdeclarative/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml:26:5 Parameter "touchPoints" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
      agent:2023/02/02 21:49:28 build.go:403: 160: QWARN  : tst_QQuickMultiPointTouchArea::signalTest() qt.qml.context: file:///home/qt/work/qt/qtdeclarative/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml:24:5 Parameter "touchPoints" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
      agent:2023/02/02 21:49:28 build.go:403: 160: QWARN  : tst_QQuickMultiPointTouchArea::signalTest() qt.qml.context: file:///home/qt/work/qt/qtdeclarative/tests/auto/quick/qquickmultipointtoucharea/data/signalTest.qml:25:5 Parameter "touchPoints" is not declared. Injection of parameters into signal handlers is deprecated. Use JavaScript functions with formal parameters instead.
      

      The code assumes it's the signal argument, but complains about the lack of formal parameter syntax. Hopefully this isn't a behavior change since old versions (did it always prefer signal arguments?) Perhaps we should rename one or the other. Renaming the signal arguments seems easier. In that case, if someone wrote code as in the autotest, "touchPoints" would end up switching to the property; whereas if they have heeded the warning already and written a JS function with a named argument, it doesn't matter what the name is.

      Also, the property is not declared CONSTANT... clazy notices.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            srutledg Shawn Rutledge
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes