diff options
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 3926436b07..5a17a45c74 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6707,7 +6707,14 @@ void QWidget::clearFocus() } QTLWExtra *extra = window()->d_func()->maybeTopData(); - QObject *originalFocusObject = (extra && extra->window) ? extra->window->focusObject() : nullptr; + QObject *originalFocusObject = nullptr; + if (extra && extra->window) { + originalFocusObject = extra->window->focusObject(); + // the window's focus object might already be nullptr if we are in the destructor, but we still + // need to update QGuiApplication and input context if we have a focus widget. + if (!originalFocusObject) + originalFocusObject = focusWidget(); + } QWidget *w = this; while (w) { |