From 0857db89bf2d36a1501c708521daacdbc83d5c5b Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 6 Dec 2017 17:45:53 +0100 Subject: Widgets: check if parent exists before calling parent->locale() If a top level, parentless widget has Qt::WA_WindowPropagation set, Qt will crash when trying to resolve the widgets locale. The reason is that we try to access the QLocale of the non-existing parent. This patch will add a check if a parent exists before trying to access it. Task-number: QTBUG-61213 Change-Id: I09a6351a12dc1fffab3069b70e3d7b3932317c85 Reviewed-by: Edward Welbourne --- src/widgets/kernel/qwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b57a0d4779..b38565493e 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6007,9 +6007,9 @@ void QWidgetPrivate::resolveLocale() Q_Q(const QWidget); if (!q->testAttribute(Qt::WA_SetLocale)) { - setLocale_helper(q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation) - ? QLocale() - : q->parentWidget()->locale()); + QWidget *parent = q->parentWidget(); + setLocale_helper(!parent || (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) + ? QLocale() : parent->locale()); } } -- cgit v1.2.3