Skip to content

Commit

Permalink
QPainter: Skip drawing text if target rect is invalid
Browse files Browse the repository at this point in the history
If drawText() is passed an empty/invalid target rectangle, we would
still go though the motions of laying out and painting the
text. Output would normally be empty, as expected, since the clipping
would take of it. But for paint devices with limited clipping support,
like QSvgGenerator in 1.2 Tiny mode, the text would wrongly show up.

Add a shortcut to skip painting text in this case.

Fixes: QTBUG-127114
Pick-to: 6.8
Change-Id: Ia7de3e7d2493218fc2a0f6cb0e815285ddceeb1d
Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
  • Loading branch information
aavit committed Aug 7, 2024
1 parent 6899008 commit c7df8dd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gui/painting/qpainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7104,6 +7104,13 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,

Q_ASSERT( !((tf & ~Qt::TextDontPrint)!=0 && option!=nullptr) ); // we either have an option or flags

if (_r.isEmpty()) {
if (!brect)
return;
else
tf |= Qt::TextDontPrint;
}

if (option) {
tf |= option->alignment();
if (option->wrapMode() != QTextOption::NoWrap)
Expand Down

0 comments on commit c7df8dd

Please sign in to comment.