Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.3.2
-
None
Description
I have a QWindow that is embedded in a native Win32 application, actually inside a C# WPF HWNDHost control. When I perform a drag event from the Windows Explorer, the dragEnter event seems to be sent from a different thread than the main QThread. I'm getting error:
ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread 0x0x26a414deb00. Receiver 'QWidgetClassWindow' (of type 'QWidgetWindow') was created in thread 0x0x26a40053fd0", file C:\Src\qt\qtbase\src\corelib\kernel\qcoreapplication.cpp, line 564 ( in C:\Src\qt\qtbase\src\corelib\kernel\qcoreapplication.cpp::)
I assumed the QCoreApplication would get the drag enter event from the OS, but it seems it is received from a different thread and not forwarded?
Here is the stack trace:
Qt6Cored.dll!QCoreApplicationPrivate::checkReceiverThread(QObject * receiver) Line 558 C++ Qt6Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 2655 C++ > BDAImageAcquireNative.dll!bda::BDAQApplication::notify(QObject * aReceiver, QEvent * aEvent) Line 48 C++ Qt6Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 1082 C++ Qt6Cored.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Line 1500 C++ Qt6Guid.dll!QGuiApplicationPrivate::processDrag(QWindow * w, const QMimeData * dropData, const QPoint & p, QFlags<Qt::DropAction> supportedActions, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers) Line 3272 C++ Qt6Guid.dll!QWindowSystemInterface::handleDrag(QWindow * window, const QMimeData * dropData, const QPoint & p, QFlags<Qt::DropAction> supportedActions, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers) Line 873 C++ qwindowsd.dll!QWindowsOleDropTarget::handleDrag(QWindow * window, unsigned long grfKeyState, const QPoint & point, unsigned long * pdwEffect) Line 504 C++ qwindowsd.dll!QWindowsOleDropTarget::DragEnter(IDataObject * pDataObj, unsigned long grfKeyState, _POINTL pt, unsigned long * pdwEffect) Line 533 C++
The top is innermost, and at the bottom it says "external code"
I guess the trigger comes from the native window into QWindowsOleDropTarget::DragEnter and via QWindowSystemInterface::handleDrag() into the static QGuiApplicationPrivate::processDrag(). Since it's static, it just sends the event further, but stays in the wrong thread.