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

Not possible to Drag'n Drop files

    XMLWordPrintable

    Details

    • Platform/s:
      macOS
    • Commits:
      629292321c3678a052d00ace8749bf6ea832d11a (qt/qtbase/5.15)

      Description

      It is not possible to drag multiple files in macOS Mojave in Qt 5.12

      One item is possible to drag, but multiple items not and then dragging is disabled completely for everything.

      In my application I can't even drag one item. No drag is initiated. ( works correctly in Qt 5.11.2 )

      Example output:

      2018-11-21 08:29:58.736 zbug_dnd_mojave_mm[41743:177885] NSException caught
      2018-11-21 08:29:58.736 zbug_dnd_mojave_mm[41743:177885] Name: NSGenericException
      2018-11-21 08:29:58.736 zbug_dnd_mojave_mm[41743:177885] Reason: There are 2 items on the pasteboard, but 1 drag images. There must be 1 draggingItem per pasteboardItem.
      QDragManager::drag in possibly invalid state
      QDragManager::drag in possibly invalid state
      #include <QtWidgets>
      
      
      #import "Foundation/Foundation.h"
      
      class TreeView : public QTreeView
      {
          Q_OBJECT
      public:
          void mousePressEvent(QMouseEvent *event) override
          {
              auto drag = new QDrag(this);
              auto *mimeData = new QMimeData();
              QList<QUrl> urlList = { QUrl(), QUrl() };
              mimeData->setUrls(urlList);
              drag->setMimeData(mimeData);
              try {
                  drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
              } catch (NSException *exception) {
                  NSLog( @"NSException caught" );
                  NSLog( @"Name: %@", exception.name);
                  NSLog( @"Reason: %@", exception.reason );
              }
          }
      };
      
      
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          auto view = new TreeView;
      
          view->setDragEnabled(true);
          view->show();
      
          return QApplication::exec();
      }
      
      #include "bug_dnd_mojave.moc" 

       

      Official Apple  release notes mention this exception in mojave in release notes

      https://developer.apple.com/documentation/macos_release_notes/macos_mojave_10_14_release_notes/appkit_release_notes_for_macos_10_14?language=objc

       

      I have also this warning messages ( not sure if this can affect dragging problem )

      When compiling I have this warnings when linking for all macOS frameworks ( many warnings )

      ld: warning: text-based stub file /System/Library/Frameworks//CoreGraphics.framework/Versions/A/CoreGraphics.tbd and library file /System/Library/Frameworks//CoreGraphics.framework/Versions/A/CoreGraphics are out of sync. Falling back to library file for linking. 

      Reinstalling CommandLineTools does not help

      sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.old
      xcode-select --install
      sudo rm -rf /Library/Developer/CommandLineTools.old

       

      I have already reported to QBS for Qt 5.11.2 but I have solved this by using different compiler ( default autodetected compiler linked app to 10.14 libs instead of 10.13 libs I guess )

      https://bugreports.qt.io/browse/QBS-1397

        Attachments

        1. bad-qt.5.12.0.mov
          988 kB
        2. bad-qt.5.9.6-sdk14.mov
          1.06 MB
        3. compile_commands.json
          2 kB
        4. good-qt5.9.6-sdk13.mov
          2.24 MB
        5. image-2021-01-13-19-33-06-691.png
          image-2021-01-13-19-33-06-691.png
          261 kB
        6. treedrag.zip
          2 kB
        For Gerrit Dashboard: QTBUG-71939
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            tpochep Timur Pocheptsov
            Reporter:
            fbucek fbucek
            Votes:
            24 Vote for this issue
            Watchers:
            36 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews