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

QQuickSwipeDelegate leaks memory

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • None
    • 6.0.3
    • Quick: Controls 2
    • None

    Description

      To reproduce, swipe one of the items to the left and click delete.

          import QtQuick
          import QtQuick.Controls
      
          ApplicationWindow {
              width: 640
              height: 480
              visible: true
              title: qsTr("Hello World")
      
              ListView {
                  id: listView
                  anchors.fill: parent
                  model: ListModel {
                      ListElement { sender: "Bob Bobbleton"; title: "How are you going?" }
                      ListElement { sender: "Rug Emporium"; title: "SALE! All rugs MUST go!" }
                      ListElement { sender: "Electric Co."; title: "Electricity bill 15/07/2016 overdue" }
                      ListElement { sender: "Tips"; title: "Five ways this tip will save your life" }
                  }
                  delegate: SwipeDelegate {
                      id: swipeDelegate
                      text: model.sender + " - " + model.title
                      width: parent.width
      
                      ListView.onRemove: SequentialAnimation {
                          PropertyAction {
                              target: swipeDelegate
                              property: "ListView.delayRemove"
                              value: true
                          }
                          NumberAnimation {
                              target: swipeDelegate
                              property: "height"
                              to: 0
                              easing.type: Easing.InOutQuad
                          }
                          PropertyAction {
                              target: swipeDelegate
                              property: "ListView.delayRemove"
                              value: false
                          }
                      }
      
                      swipe.right: Label {
                          id: deleteLabel
                          text: qsTr("Delete")
                          color: "white"
                          verticalAlignment: Label.AlignVCenter
                          padding: 12
                          height: parent.height
                          anchors.right: parent.right
      
                          SwipeDelegate.onClicked: listView.model.remove(index)
      
                          background: Rectangle {
                              color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
                          }
                      }
                  }
              }
          }
      

      Then

          valgrind --leak-check=full --log-file=valgrind.txt ./untitled1
      

      results in (amongst other unrelated output):

          ==97023== 307,502 (200 direct, 307,302 indirect) bytes in 1 blocks are definitely lost in loss record 6,979 of 6,980
          ==97023==    at 0x483BE63: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
          ==97023==    by 0x5629EB9: createRefCounted (qqmlcontextdata_p.h:74)
          ==97023==    by 0x5629EB9: create (qqmlobjectcreator.cpp:182)
          ==97023==    by 0x5629EB9: QQmlObjectCreator::create(int, QObject*, QQmlInstantiationInterrupt*, int) (qqmlobjectcreator.cpp:158)
          ==97023==    by 0x55B768F: QQmlComponentPrivate::beginCreate(QQmlRefPointer<QQmlContextData>) (qqmlcomponent.cpp:934)
          ==97023==    by 0x55B7818: QQmlComponent::beginCreate(QQmlContext*) (qqmlcomponent.cpp:887)
          ==97023==    by 0x14394AC5: QQuickSwipePrivate::createDelegateItem(QQmlComponent*) (qquickswipedelegate.cpp:227)
          ==97023==    by 0x14396233: QQuickSwipePrivate::createRightItem() (qquickswipedelegate.cpp:345)
          ==97023==    by 0x143966FE: QQuickSwipePrivate::createRelevantItemForDistance(double) (qquickswipedelegate.cpp:283)
          ==97023==    by 0x14397078: QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem*, QMouseEvent*) (qquickswipedelegate.cpp:843)
          ==97023==    by 0x143974A4: QQuickSwipeDelegate::mouseMoveEvent(QMouseEvent*) (qquickswipedelegate.cpp:1294)
          ==97023==    by 0x12C994B7: QQuickItem::event(QEvent*) (qquickitem.cpp:8269)
          ==97023==    by 0x5C0A058: QCoreApplication::notifyInternal2(QObject*, QEvent*) (qcoreapplication.cpp:1040)
          ==97023==    by 0x12D3C844: QQuickWindowPrivate::deliverMatchingPointsToItem(QQuickItem*, bool, QPointerEvent*, bool) (qquickwindow.cpp:2962)
      

      Attachments

        Issue Links

          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
              mitch_curtis Mitch Curtis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes