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

Drag attached property crashes when item it's attached to is destroyed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • None
    • 5.9.3
    • None
    • Qt 5.9.3 on KDE neon
    • a21d4395f4f9afea52b6c2da359ce6ad21ebc763 (qt/qtbase/5.13)

    Description

      When using the Drag attached property to drag items between windows, when the item the Drag is attached to is destroyed, the application crashes as soon as someone tries to access the drag's mime data, such as a DropArea

      Take the following example. Drag the magenta rectangle over the DropArea, move it around there a bit and as soon as the Timer resets the Repeater model (which causes the Rectangle to be destroyed), the application crashes. Ideally it would either cancel the drag drop operation or continue on with a copy of the data.

      import QtQuick 2.8
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
      
          Timer {
              id: destroyTimer
              interval: 1000
              onTriggered: repeater.model = 0
          }
      
          Repeater {
              id: repeater
              model: 1
      
              Rectangle {
                  width: 100
                  height: 100
                  color: "#f0f"
      
                  Drag.active: dragArea.drag.active
                  Drag.dragType: Drag.Automatic
                  Drag.onDragStarted: destroyTimer.start()
      
                  MouseArea {
                      id: dragArea
                      anchors.fill: parent
                      drag.target: parent
                  }
              }
          }
      
          DropArea {
              width: 100
              height: 100
              y: 100
      
              Rectangle {
                  anchors.fill: parent
                  color: "#999"
      
                  Text {
                      text: "Drop here"
                  }
              }
          }
      }
      

      (Use case: in KDE Plasma we have screenshot previews in the notification center which can be dragged to other applications. When the notification times out or is closed during drag, the desktop shell would crash)

      Attachments

        Issue Links

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

          Activity

            People

              yulong.bai Bai Yulong
              broulik Kai Uwe Broulik
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes