summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2025-07-15 14:57:20 -0700
committerIvan Solovev <ivan.solovev@qt.io>2025-08-27 18:46:19 +0000
commit02f5cc7ed218e663dd2da6388f7ef1504cd7cfef (patch)
tree21828ec71fba7051594cdfe5e398f6b8653857f5
parentda434e2defba42646c124e4f9778ce3d653b2c44 (diff)
Examples: don't overflow a QRect with adjusted()
Required after 1145e1709d1072f7dd45683e9c25a14615603854 made QRect use QCheckedInt. We can avoid this by simply using QRectF one step earlier in the calculation, which a) expands the range from ±2^31 to ±2^53 and b) neatly avoids infinite zooming by not doing anything after 2^53 (because 2^53 + 1 = 2^53). Fixes: QTBUG-138504 Pick-to: 6.10 Change-Id: Ibe382ad9b98bbfb9fde6fffd94bd733a4b999852 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
-rw-r--r--examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
index bbe694831d2..5159a1aa685 100644
--- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
+++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
@@ -76,8 +76,8 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
painter.translate(newX, newY);
painter.scale(scaleFactor, scaleFactor);
- const QRectF exposed = painter.transform().inverted().mapRect(rect())
- .adjusted(-1, -1, 1, 1);
+ QRectF exposed = painter.transform().inverted().mapRect(rect());
+ exposed = exposed.adjusted(-1, -1, 1, 1);
painter.drawPixmap(exposed, previewPixmap, exposed);
painter.restore();
}