diff options
| author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2023-03-08 11:49:15 +0100 |
|---|---|---|
| committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2023-03-09 23:04:02 +0000 |
| commit | fd23a222efe189607eebd5c6782ca73eafa7080c (patch) | |
| tree | 00c09ccf34dcf6d40d5ef8f5055c977701836770 /src | |
| parent | 9677fcf9aa4898a7ba98fa97e0ff4645ea5db3ab (diff) | |
Fix bug when center aligning anchors on items with fractional sizes
It seems that the old code assumed that all widths and heights were
limited to integers (despite that the argument was qreal)
Amends 50482f69af0b9392424dfdad5376fcb09be36d46
Fixes: QTBUG-95224
Change-Id: I6d003eb09702828a39cb1172f6c62b7fe240ca60
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/quick/items/qquickanchors.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/quick/items/qquickanchors.cpp b/src/quick/items/qquickanchors.cpp index dfb8ce0a18..e6de648313 100644 --- a/src/quick/items/qquickanchors.cpp +++ b/src/quick/items/qquickanchors.cpp @@ -49,11 +49,7 @@ static inline qreal hcenter(const QQuickItem *item) if (!QQuickAnchorsPrivate::get(anchors)->centerAligned) return width / 2; } - int iw = width; - if (iw % 2) - return (width + 1) / 2; - else - return width / 2; + return qRound(width / 2); } static inline qreal vcenter(const QQuickItem *item) @@ -63,11 +59,7 @@ static inline qreal vcenter(const QQuickItem *item) if (!QQuickAnchorsPrivate::get(anchors)->centerAligned) return height / 2; } - int ih = height; - if (ih % 2) - return (height + 1) / 2; - else - return height / 2; + return qRound(height / 2); } //local position |
