From 174061f9f32ac76c6b8a6d155d772e37708d8cfc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 31 Jul 2019 10:23:39 +0200 Subject: QHighDPI: Fix broken scaling of QPoint(F) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason, the overload resolution of the High DPI scale() functions introduced by b6ded193ee64ffe67df6d22e7a23aa1ea9e02ec7 chose the wrong overloads for QPointF and/or QPoint; it fell back to the generic template intended for qreal, QSize, etc, ignoring the origin. Remove the template and spell out all overloads. Fixes: QTBUG-77255 Change-Id: I5661f16f7326f65156f646f430f5a0c71d5302d2 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qhighdpiscaling_p.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/gui/kernel/qhighdpiscaling_p.h') diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h index 3410c1d345..c43641b8c9 100644 --- a/src/gui/kernel/qhighdpiscaling_p.h +++ b/src/gui/kernel/qhighdpiscaling_p.h @@ -59,6 +59,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -117,13 +118,26 @@ private: namespace QHighDpi { -template -inline T scale(const T &value, qreal scaleFactor, QPoint origin = QPoint(0, 0)) +inline qreal scale(qreal value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) { - Q_UNUSED(origin) return value * scaleFactor; } +inline QSize scale(const QSize &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * scaleFactor; +} + +inline QSizeF scale(const QSizeF &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * scaleFactor; +} + +inline QVector2D scale(const QVector2D &value, qreal scaleFactor, QPointF /* origin */ = QPointF(0, 0)) +{ + return value * float(scaleFactor); +} + inline QPointF scale(const QPointF &pos, qreal scaleFactor, QPointF origin = QPointF(0, 0)) { return (pos - origin) * scaleFactor + origin; -- cgit v1.2.3