From b13ba1e42e51dad1a86f60094805390d6dc3e713 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Wed, 2 Feb 2022 13:15:43 +0000 Subject: [PATCH] Fix crash due to use of native widgets on Windows Qt has corner cases when all of its widgets are native widgets. This particular crash was a loop between QWidget::create() and QWidget::createWinId(). --- src/private/DragController.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/private/DragController.cpp b/src/private/DragController.cpp index 2a536fcf..c5e31e39 100644 --- a/src/private/DragController.cpp +++ b/src/private/DragController.cpp @@ -788,6 +788,12 @@ static QWidgetOrQuick *qtTopLevelForHWND(HWND hwnd) // Case not supported for QtQuick. const QWidgetList widgets = qApp->topLevelWidgets(); for (QWidget *widget : widgets) { + if (!widget->windowHandle()) { + // Don't call winId on windows that don't have it, as that will force all its childrens to have it, + // and that's not very stable. a top level might not have one because it's being destroyed, or because + // it's a top-level just because it has't been reparented I guess. + continue; + } if (hwnd == ( HWND )widget->winId()) { return widget; }