diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2017-12-06 17:45:53 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2017-12-18 12:08:17 +0000 |
commit | 0857db89bf2d36a1501c708521daacdbc83d5c5b (patch) | |
tree | 2c632a5d0d8ada6aa1c29df2cdddbb2a0d8959c8 /src/widgets | |
parent | 3841a7dd49667ceabdcbc416fa1e149bed7ed86e (diff) |
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 <edward.welbourne@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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()); } } |