Skip to content

Commit

Permalink
Consistently check for nullptr in QGraphicsTextItem::inputMethodQuery
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
(cherry picked from commit 7edf0fb)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
  • Loading branch information
vohi authored and Qt Cherry-pick Bot committed Mar 19, 2021
1 parent f4110ab commit 7b9fc29
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/widgets/graphicsview/qgraphicsitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 7b9fc29

Please sign in to comment.