diff options
author | Sergio Martins <sergio.martins@kdab.com> | 2018-03-02 18:36:20 +0000 |
---|---|---|
committer | Sérgio Martins <sergio.martins@kdab.com> | 2018-03-12 15:27:28 +0000 |
commit | 2b4078cbb0d6bde9a681d1b3120aa586ab6c162d (patch) | |
tree | 578af1000c5cea48fc6c50e1bee75730ff970f66 | |
parent | 4495a4d99adf5b078e3a783ced9265391bb4174e (diff) |
Fix QLabel crash if buddy's lifetime is too short
If buddy is deleted then QLabel will still try to deliver the
shortcut event to it, in QLabel::event(), and crash.
For this cherry-pick removed all nice-to-haves and only
fixed dereferencing the null pointer.
Task-Id: QTBUG-66841
Change-Id: Ib6a36a9f99cee31afe1f88eb77f5b6cafb8b1086
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
(cherry picked from commit c082d84d5d7fdbfb64de18f06a8ddbc77f2e6de4)
Reviewed-by: Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
-rw-r--r-- | src/widgets/widgets/qlabel.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp index e3225800cc..46afac700a 100644 --- a/src/widgets/widgets/qlabel.cpp +++ b/src/widgets/widgets/qlabel.cpp @@ -964,6 +964,8 @@ bool QLabel::event(QEvent *e) QShortcutEvent *se = static_cast<QShortcutEvent *>(e); if (se->shortcutId() == d->shortcutId) { QWidget * w = d->buddy; + if (!w) + return QFrame::event(e); if (w->focusPolicy() != Qt::NoFocus) w->setFocus(Qt::ShortcutFocusReason); #if QT_CONFIG(abstractbutton) |