Crash with QDragManager
-
Dear all,
I've an issue with the member
m_currentDropTargetfrom the internalQDragManagerinstance.
In my application, the user can open aQMainWindowand 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_currentDropTargetis 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.
-
I've finaly fixed the issue.
The problem came from aneventfilterset 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 theQDragManagerto 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.- I think it should be written somewhere in the documentation that eventFilter should return true in case of
QDropEvent - Why doesn't the
QDragManagerstore aQPointerinstead of a simple pointer to the target object ?
Regards
- I think it should be written somewhere in the documentation that eventFilter should return true in case of
-
Dear all,
I've an issue with the member
m_currentDropTargetfrom the internalQDragManagerinstance.
In my application, the user can open aQMainWindowand 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_currentDropTargetis 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.
@NicolasS
Qt version?
Platform?
System?
Some DnD code? -
Qt 5.9.4 (bug was already present in 5.8)
Windows 10 64bits + Microsoft Visual 2017Hard 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. -
I've finaly fixed the issue.
The problem came from aneventfilterset 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 theQDragManagerto 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.- I think it should be written somewhere in the documentation that eventFilter should return true in case of
QDropEvent - Why doesn't the
QDragManagerstore aQPointerinstead of a simple pointer to the target object ?
Regards
- I think it should be written somewhere in the documentation that eventFilter should return true in case of
-
I've finaly fixed the issue.
The problem came from aneventfilterset 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 theQDragManagerto 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.- I think it should be written somewhere in the documentation that eventFilter should return true in case of
QDropEvent - Why doesn't the
QDragManagerstore aQPointerinstead of a simple pointer to the target object ?
Regards
@NicolasS
why do you install an event filter on all children for the drop event in the first place? o.O - I think it should be written somewhere in the documentation that eventFilter should return true in case of
-
Sorry I wasn't very clear on that part.
TheeventFilteris 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 theeventFilter.