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

Drag.imageSource property should work with other images, not just screen grabs

    XMLWordPrintable

Details

    • ac78bf707 (dev), 0290e0fd5 (dev)

    Description

      If we modify qtdeclarative/src/quick/doc/snippets/qml/externaldrag.qml like this:

      import QtQuick
      
      Item {
          width: 200; height: 200
      
          Rectangle {
              anchors.centerIn: parent
              width: text.implicitWidth + 20; height: text.implicitHeight + 10
              color: "green"
              radius: 5
      
              Drag.dragType: Drag.Automatic
              Drag.supportedActions: Qt.CopyAction
              Drag.mimeData: {
                  "text/plain": "Copied text"
              }
              Drag.imageSource: "icon.svg" // <----
              Drag.active: dragHandler.active
      
              Text {
                  id: text
                  anchors.centerIn: parent
                  text: "Drag me"
              }
      
              DragHandler {
                  id: dragHandler
              }
          }
      }
      

      it should work (discovered while testing https://codereview.qt-project.org/c/qt/qtdeclarative/+/518814 : the new imageSourceSize property). Instead, it tries to load the image, doesn't succeed, and replaces it with the usual QPainter-rendered image containing "Copied text":

      1  QPainter::drawText(QPointF const&, QString const&, qpainter.cpp             5592 
      2  QPainter::drawText(QPointF const&, QString const&) qpainter.cpp             5428 
      3  QPainter::drawText(int, int, QString const&)       qpainter.h               840  
      4  QCocoaDrag::dragPixmap(QDrag *, QPoint&) const     qcocoadrag.mm            281  
      5  QCocoaDrag::drag(QDrag *)                          qcocoadrag.mm            111  
      6  QDragManager::drag(QDrag *)                        qdnd.cpp                 81   
      7  QDrag::exec(QFlags<Qt::DropAction>, Qt::DropAction qdrag.cpp                248  
      8  QDrag::exec(QFlags<Qt::DropAction>)                qdrag.cpp                203  
      9  QQuickDragAttachedPrivate::startDrag(QFlags<Qt::Dr qquickdrag.cpp           814  
      10 QQuickDragAttached::setActive(bool)                qquickdrag.cpp           232  
      11 QQuickDragAttached::qt_static_metacall(QObject *,  moc_qquickdrag_p.cpp     870  
      12 QQuickDragAttached::qt_metacall(QMetaObject::Call, moc_qquickdrag_p.cpp     923  
      13 void QQmlPropertyData::doMetacall<(QMetaObject::Ca qqmlpropertydata_p.h     360  
      14 QQmlPropertyData::writeProperty(QObject *, void *, qqmlpropertydata_p.h     378  
      15 QQmlPropertyPrivate::write(QObject *, QQmlProperty qqmlproperty.cpp         1500 
      16 QV4::QObjectWrapper::setProperty(QV4::ExecutionEng qv4qobjectwrapper.cpp    757  
      17 QV4::QObjectWrapper::setQmlProperty(QV4::Execution qv4qobjectwrapper.cpp    572  
      18 QV4::QQmlTypeWrapper::virtualPut(QV4::Managed *, Q qqmltypewrapper.cpp      334  
      19 QV4::Object::put(QV4::PropertyKey, QV4::Value cons qv4object_p.h            287  
      20 QV4::Object::virtualResolveLookupSetter(QV4::Objec qv4object.cpp            814  
      21 QV4::QQmlTypeWrapper::virtualResolveLookupSetter(Q qqmltypewrapper.cpp      532  
      22 QV4::Object::resolveLookupSetter(QV4::ExecutionEng qv4object_p.h            344  
      23 QV4::Lookup::resolveSetter(QV4::ExecutionEngine *, qv4lookup.cpp            532  
      24 QV4::Lookup::setterGeneric(QV4::Lookup *, QV4::Exe qv4lookup.cpp            538  
      25 QV4::Moth::VME::interpret(QV4::JSTypesStackFrame * qv4vme_moth.cpp          703  
      26 QV4::Moth::VME::exec(QV4::JSTypesStackFrame *, QV4 qv4vme_moth.cpp          487  
      27 qfoDoCall(QV4::FunctionObject const *, QV4::Value  qv4functionobject.cpp    526  
      28 QV4::ArrowFunction::virtualCall(QV4::FunctionObjec qv4functionobject.cpp    556  
      29 QV4::FunctionObject::call(QV4::Value const *, QV4: qv4functionobject_p.h    171  
      30 QV4::FunctionObject::call(QV4::JSCallData const&)  qv4jscall_p.h            108  
      31 QJSValue::call(QList<QJSValue> const&) const       qjsvalue.cpp             707  
      32 QQuickItemGrabResult::event(QEvent *)              qquickitemgrabresult.cpp 221  
      33 QCoreApplicationPrivate::notify_helper(QObject *,  qcoreapplication.cpp     1312 
      34 doNotify(QObject *, QEvent *)                      qcoreapplication.cpp     1239 
      35 QCoreApplication::notify(QObject *, QEvent *)      qcoreapplication.cpp     1222 
      36 QGuiApplication::notify(QObject *, QEvent *)       qguiapplication.cpp      1994 
      37 QCoreApplication::notifyInternal2(QObject *, QEven qcoreapplication.cpp     1138 
      38 QCoreApplication::sendEvent(QObject *, QEvent *)   qcoreapplication.cpp     1581 
      39 QCoreApplicationPrivate::sendPostedEvents(QObject  qcoreapplication.cpp     1936 
      40 QCoreApplication::sendPostedEvents(QObject *, int) qcoreapplication.cpp     1770 
      41 QCocoaEventDispatcherPrivate::processPostedEvents( qcocoaeventdispatcher.mm 900  
      42 QCocoaEventDispatcherPrivate::postedEventsSourceCa qcocoaeventdispatcher.mm 922  
      43 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FU (arm64e) /System/Library      
      44 __CFRunLoopDoSource0                               (arm64e) /System/Library      
      45 __CFRunLoopDoSources0                              (arm64e) /System/Library      
      46 __CFRunLoopRun                                     (arm64e) /System/Library      
      47 CFRunLoopRunSpecific                               (arm64e) /System/Library      
      48 RunCurrentEventLoopInMode                          (arm64e) /System/Library      
      49 ReceiveNextEventCommon                             (arm64e) /System/Library      
      50 _BlockUntilNextEventMatchingListInModeWithFilter   (arm64e) /System/Library      
      51 _DPSNextEvent                                      (arm64e) /System/Library      
      52 -[NSApplication(NSEventRouting) _nextEventMatching (arm64e) /System/Library      
      53 -[NSApplication run]                               (arm64e) /System/Library      
      54 QCocoaEventDispatcher::processEvents(QFlags<QEvent qcocoaeventdispatcher.mm 406  
      55 QEventLoop::processEvents(QFlags<QEventLoop::Proce qeventloop.cpp           100  
      56 QEventLoop::exec(QFlags<QEventLoop::ProcessEventsF qeventloop.cpp           191  
      57 QCoreApplication::exec()                           qcoreapplication.cpp     1482 
      58 main                                               main.cpp                 648  
      59 start                                              (arm64e) /usr/lib/dyld        
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-120489
          # Subject Branch Project Status CR V

          Activity

            People

              srutledg Shawn Rutledge
              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