Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Drag and Drop issues on Windows
Forum Updated to NodeBB v4.3 + New Features

Drag and Drop issues on Windows

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 984 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Isaac LightburnI Offline
    Isaac LightburnI Offline
    Isaac Lightburn
    wrote on last edited by Isaac Lightburn
    #1

    I'm the developer of OpenKJ, an open source karaoke hosting app. I'm having a weird problem, specifically on Windows. Doesn't happen on Linux or macOS.

    I have several QTableViews that are used to display/manipulate rotation singers, song queues, break music playlists, etc. I use subclassed QAbstractTableModels to populate them and handle all of the drag and drop stuff for reordering inside views and for dragging content into them. Everything works perfectly except for on Windows. On that platform, drag and drop works normally on program startup, but after the program has been running for about 20 mins, drag and drop stops working completely. Always shows the drop forbidden symbol and stops calling canDropMimeData in any of the models when dragging items into the views.

    Anyone else ever run into this? If so, any idea how to fix it?

    Qt version is 5.15.0 using MSVC2019

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Do you have any particular check to forbid dropping ?
      Does it happen on every widget that are drop targets ?
      Which version of Windows are you running ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Isaac LightburnI Offline
        Isaac LightburnI Offline
        Isaac Lightburn
        wrote on last edited by
        #3

        Just the normal mime types checks, but that's in canDropMimeData, which never gets called again once the problem starts happening.

        Every drop target in the program is affected (3 different tableviews w/ separate models).

        This is Windows 10 Pro, so far all of the users reporting the problem are also on Windows 10.

        Source is at https://github.com/openkj/openkj btw

        1 Reply Last reply
        0
        • Isaac LightburnI Offline
          Isaac LightburnI Offline
          Isaac Lightburn
          wrote on last edited by
          #4

          Did some deeper digging on this. After the bug is triggered, exceptions start getting thrown as soon as a drag starts. Had to actually load the code up in Visual Studio and use the debugger there to see the exceptions.

          Here's the exception it's throwing:
          Exception thrown at 0x74FD46D2 (KernelBase.dll) in openkj.exe: 0x80010012: The callee (server [not server application]) is not available and disappeared; all connections are invalid. The call did not execute.

          The call stack shows that it's triggering on the Qt side after a call to:
          const HRESULT r = DoDragDrop(dropDataObject, windowDropSource, allowedEffects, &resultEffect);
          from ole32.dll in qwindowsdrag.cpp on line 700 in the QWindowsDrag.cpp file.

          1 Reply Last reply
          0
          • Isaac LightburnI Offline
            Isaac LightburnI Offline
            Isaac Lightburn
            wrote on last edited by
            #5

            Was able to create a super minimal example.

            Seems to be a problem with using Qt and GStreamer together.

            https://github.com/ILightburn/dnd-win-bug-minimal-example

            1 Reply Last reply
            0
            • Isaac LightburnI Offline
              Isaac LightburnI Offline
              Isaac Lightburn
              wrote on last edited by
              #6

              For anyone who stumbles across this and is having similar issues, here's what was causing the bug.

              Qt uses COM for handling drag and drop events on Windows.
              GStreamer currently has a bug in their WASAPI audio backend that causes COM objects to be destroyed that it didn't create when some threads exit.
              GStreamer was destroying the COM object that Qt was using, causing Qt's drag and drop functionality to stop working.

              The fix is to make GStreamer default to using DirectSound instead of WASAPI for its audio sink. Add the following code, after you init GStreamer:

              #ifdef Q_OS_WIN
               // Use directsoundsink by default because of buggy wasapi plugin.
               GstRegistry *reg = gst_registry_get();
               if (reg) {
                 GstPluginFeature *directsoundsink = gst_registry_lookup_feature(reg, "directsoundsink");
                 GstPluginFeature *wasapisink = gst_registry_lookup_feature(reg, "wasapisink");
                 if (directsoundsink && wasapisink) {
                   gst_plugin_feature_set_rank(directsoundsink, GST_RANK_PRIMARY);
                   gst_plugin_feature_set_rank(wasapisink, GST_RANK_SECONDARY); 
                 }
                 if (directsoundsink) gst_object_unref(directsoundsink);
                 if (wasapisink) gst_object_unref(wasapisink);
               }
              #endif
              
              1 Reply Last reply
              1
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Nice !!

                Thanks for sharing your discovery !

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved