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. Crash with QDragManager
Forum Updated to NodeBB v4.3 + New Features

Crash with QDragManager

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.6k 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.
  • N Offline
    N Offline
    NicolasS
    wrote on last edited by
    #1

    Dear all,

    I've an issue with the member m_currentDropTarget from the internal QDragManager instance.
    In my application, the user can open a QMainWindow and do some drag and drop between child widgets.

    After a successful drop, if the user closes the mainwindow and re-open it again, the next drag movement will lead to an exception because m_currentDropTarget is still pointing to a child widget of the destroyed window.

    Since this class is internal, I don't have any way to interact with it.
    Any tip on how to reset the internel state of the QDragManager ?

    Thanks by advance.

    raven-worxR 1 Reply Last reply
    0
    • N Offline
      N Offline
      NicolasS
      wrote on last edited by
      #4

      I've finaly fixed the issue.
      The problem came from an eventfilter set on all children of the mainwindow which managed all drag'n drop events. It was returning true in the drop event case (It manages the drop so it should return true, isn't it ???).
      Returning true was preventing the QDragManager to reset it's internal target.

      I've spent 2days debugging the program, and trying to understand the situation while the fix was just to return false instead of true in the eventFilter.
      Despite having carefuly read the doc on Drag'n drop management, I still have issue on how to manage drag'n drop correctly.

      1. I think it should be written somewhere in the documentation that eventFilter should return true in case of QDropEvent
      2. Why doesn't the QDragManager store a QPointer instead of a simple pointer to the target object ?

      Regards

      raven-worxR 1 Reply Last reply
      0
      • N NicolasS

        Dear all,

        I've an issue with the member m_currentDropTarget from the internal QDragManager instance.
        In my application, the user can open a QMainWindow and do some drag and drop between child widgets.

        After a successful drop, if the user closes the mainwindow and re-open it again, the next drag movement will lead to an exception because m_currentDropTarget is still pointing to a child widget of the destroyed window.

        Since this class is internal, I don't have any way to interact with it.
        Any tip on how to reset the internel state of the QDragManager ?

        Thanks by advance.

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #2

        @NicolasS
        Qt version?
        Platform?
        System?
        Some DnD code?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • N Offline
          N Offline
          NicolasS
          wrote on last edited by
          #3

          Qt 5.9.4 (bug was already present in 5.8)
          Windows 10 64bits + Microsoft Visual 2017

          Hard for me to post a sample of code.

          Here's the line involving QDragManager

          Here's the call stack :

          Qt5Cored.dll!QObject::isWidgetType() Line 147 C++ Symbols loaded.
          Qt5Widgetsd.dll!qobject_cast<QWidget * __ptr64>(QObject * o) Line 741 C++ Symbols loaded.
          Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 3468 C++ Symbols loaded.
          Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1016 C++ Symbols loaded.
          Qt5Cored.dll!QCoreApplication::sendSpontaneousEvent(QObject * receiver, QEvent * event) Line 236 C++ Symbols loaded.
          Qt5Widgetsd.dll!QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent * event) Line 855 C++ Symbols loaded.
          Qt5Widgetsd.dll!QWidgetWindow::event(QEvent * event) Line 285 C++ Symbols loaded.
          Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 3722 C++ Symbols loaded.
          Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 3094 C++ Symbols loaded.
          Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1016 C++ Symbols loaded.
          Qt5Cored.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Line 233 C++ Symbols loaded.
          Qt5Guid.dll!QGuiApplicationPrivate::processDrag(QWindow * w, const QMimeData * dropData, const QPoint & p, QFlags<enum Qt::DropAction> supportedActions) Line 2922 C++ Symbols loaded.
          Qt5Guid.dll!QWindowSystemInterface::handleDrag(QWindow * window, const QMimeData * dropData, const QPoint & p, QFlags<enum Qt::DropAction> supportedActions) Line 716 C++ Symbols loaded.
          qwindowsd.dll!QWindowsOleDropTarget::handleDrag(QWindow * window, unsigned long grfKeyState, const QPoint & point, unsigned long * pdwEffect) Line 555 C++ Symbols loaded.
          qwindowsd.dll!QWindowsOleDropTarget::DragOver(unsigned long grfKeyState, _POINTL pt, unsigned long * pdwEffect) Line 606 C++ Symbols loaded.
          [External Code] Annotated Frame
          qwindowsd.dll!QWindowsDrag::drag(QDrag * drag) Line 748 C++ Symbols loaded.
          Qt5Guid.dll!QDragManager::drag(QDrag * o) Line 141 C++ Symbols loaded.
          Qt5Guid.dll!QDrag::exec(QFlags<enum Qt::DropAction> supportedActions, Qt::DropAction defaultDropAction) Line 284 C++ Symbols loaded.
          Qt5Widgetsd.dll!QAbstractItemView::startDrag(QFlags<enum Qt::DropAction> supportedActions) Line 3679 C++ Symbols loaded.
          Qt5Widgetsd.dll!QAbstractItemView::mouseMoveEvent(QMouseEvent * event) Line 1837 C++ Symbols loaded.
          Qt5Widgetsd.dll!QTreeView::mouseMoveEvent(QMouseEvent * event) Line 1990 C++ Symbols loaded.
          Qt5Widgetsd.dll!QWidget::event(QEvent * event) Line 8892 C++ Symbols loaded.
          Qt5Widgetsd.dll!QFrame::event(QEvent * e) Line 550 C++ Symbols loaded.
          Qt5Widgetsd.dll!QAbstractScrollArea::viewportEvent(QEvent * e) Line 1221 C++ Symbols loaded.
          Qt5Widgetsd.dll!QAbstractItemView::viewportEvent(QEvent * event) Line 1749 C++ Symbols loaded.
          Qt5Widgetsd.dll!QTreeView::viewportEvent(QEvent * event) Line 1327 C++ Symbols loaded.
          Qt5Widgetsd.dll!QAbstractScrollAreaPrivate::viewportEvent(QEvent * event) Line 113 C++ Symbols loaded.
          Qt5Widgetsd.dll!QAbstractScrollAreaFilter::eventFilter(QObject * o, QEvent * e) Line 129 C++ Symbols loaded.
          Qt5Cored.dll!QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject * receiver, QEvent * event) Line 1127 C++ Symbols loaded.
          Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 3718 C++ Symbols loaded.
          Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 3198 C++ Symbols loaded.
          Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1016 C++ Symbols loaded.
          Qt5Cored.dll!QCoreApplication::sendSpontaneousEvent(QObject * receiver, QEvent * event) Line 236 C++ Symbols loaded.
          Qt5Widgetsd.dll!QApplicationPrivate::sendMouseEvent(QWidget * receiver, QMouseEvent * event, QWidget * alienWidget, QWidget * nativeWidget, QWidget * * buttonDown, QPointer<QWidget> & lastMouseReceiver, bool spontaneous) Line 2702 C++ Symbols loaded.
          Qt5Widgetsd.dll!QWidgetWindow::handleMouseEvent(QMouseEvent * event) Line 630 C++ Symbols loaded.
          Qt5Widgetsd.dll!QWidgetWindow::event(QEvent * event) Line 251 C++ Symbols loaded.
          Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 3722 C++ Symbols loaded.
          Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 3094 C++ Symbols loaded.
          Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1016 C++ Symbols loaded.
          Qt5Cored.dll!QCoreApplication::sendSpontaneousEvent(QObject * receiver, QEvent * event) Line 236 C++ Symbols loaded.
          Qt5Guid.dll!QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent * e) Line 1953 C++ Symbols loaded.
          Qt5Guid.dll!QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent * e) Line 1734 C++ Symbols loaded.
          Qt5Guid.dll!QWindowSystemInterface::sendWindowSystemEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 952 C++ Symbols loaded.
          qwindowsd.dll!QWindowsGuiEventDispatcher::sendPostedEvents() Line 83 C++ Symbols loaded.

          1 Reply Last reply
          0
          • N Offline
            N Offline
            NicolasS
            wrote on last edited by
            #4

            I've finaly fixed the issue.
            The problem came from an eventfilter set on all children of the mainwindow which managed all drag'n drop events. It was returning true in the drop event case (It manages the drop so it should return true, isn't it ???).
            Returning true was preventing the QDragManager to reset it's internal target.

            I've spent 2days debugging the program, and trying to understand the situation while the fix was just to return false instead of true in the eventFilter.
            Despite having carefuly read the doc on Drag'n drop management, I still have issue on how to manage drag'n drop correctly.

            1. I think it should be written somewhere in the documentation that eventFilter should return true in case of QDropEvent
            2. Why doesn't the QDragManager store a QPointer instead of a simple pointer to the target object ?

            Regards

            raven-worxR 1 Reply Last reply
            0
            • N NicolasS

              I've finaly fixed the issue.
              The problem came from an eventfilter set on all children of the mainwindow which managed all drag'n drop events. It was returning true in the drop event case (It manages the drop so it should return true, isn't it ???).
              Returning true was preventing the QDragManager to reset it's internal target.

              I've spent 2days debugging the program, and trying to understand the situation while the fix was just to return false instead of true in the eventFilter.
              Despite having carefuly read the doc on Drag'n drop management, I still have issue on how to manage drag'n drop correctly.

              1. I think it should be written somewhere in the documentation that eventFilter should return true in case of QDropEvent
              2. Why doesn't the QDragManager store a QPointer instead of a simple pointer to the target object ?

              Regards

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #5

              @NicolasS
              why do you install an event filter on all children for the drop event in the first place? o.O

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • N Offline
                N Offline
                NicolasS
                wrote on last edited by
                #6

                Sorry I wasn't very clear on that part.
                The eventFilter is installed on the toplevel parent of all children we want to monitor and is responsible to process the event on the adequat underlying child.
                One of the advantage of this design is that the code is centralized in one part so it's easier to maintain. Maybe there's other possible design but it works in our case.
                Except that I was tricked by the code to return from the eventFilter.

                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