Skip to content

Commit

Permalink
Fix QLabel crash if buddy's lifetime is too short
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
iamsergio committed Mar 12, 2018
1 parent 4495a4d commit 2b4078c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/widgets/widgets/qlabel.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit 2b4078c

Please sign in to comment.