diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-03-17 15:26:11 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-03-19 15:46:26 +0000 |
commit | 7b9fc295ee919c4d89e846c5b24ae5f7187cfd42 (patch) | |
tree | 20fba6a6666d67c197fcf5ac2981ce22b9f6fcb4 /src/widgets/graphicsview/qgraphicsitem.cpp | |
parent | f4110ab1e2599bff8573006e85221997ba6a1194 (diff) |
Consistently check for nullptr in QGraphicsTextItem::inputMethodQuery
If dd->control is nullptr, then it's nullptr all the way, so don't
dereference it in the calls to dd->controlOffset.
Fixes static analyzer warning 9c33d9bc9b8cf438dccb63aa52afcbe0.
Change-Id: I7a61b6438422373678d4fcb66255b750c550724d
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 7edf0fbb9e8cca2e2f2695a1b5dc7a0a143bc211)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsitem.cpp')
-rw-r--r-- | src/widgets/graphicsview/qgraphicsitem.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index bad40b0cff..7dcfd47dc0 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -10311,14 +10311,16 @@ QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const v = int(inputMethodHints()); else if (dd->control) v = dd->control->inputMethodQuery(query, QVariant()); - if (v.userType() == QMetaType::QRectF) - v = v.toRectF().translated(-dd->controlOffset()); - else if (v.userType() == QMetaType::QPointF) - v = v.toPointF() - dd->controlOffset(); - else if (v.userType() == QMetaType::QRect) - v = v.toRect().translated(-dd->controlOffset().toPoint()); - else if (v.userType() == QMetaType::QPoint) - v = v.toPoint() - dd->controlOffset().toPoint(); + if (dd->control) { + if (v.userType() == QMetaType::QRectF) + v = v.toRectF().translated(-dd->controlOffset()); + else if (v.userType() == QMetaType::QPointF) + v = v.toPointF() - dd->controlOffset(); + else if (v.userType() == QMetaType::QRect) + v = v.toRect().translated(-dd->controlOffset().toPoint()); + else if (v.userType() == QMetaType::QPoint) + v = v.toPoint() - dd->controlOffset().toPoint(); + } return v; } |