From f69b5f260e301dc01c7d85cd1cb9d45582ef3d6d Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 12 May 2023 15:46:54 +0800 Subject: QQuickMaterialPlaceholderText: fix code checker complaint The message was: result of integer division used in a floating point context; possible loss of precision Fixing it revealed a test that relied on it; removed the Math.floor() work-around the test used previously. Pick-to: 6.5 Change-Id: I7c2fde1902d2013ba9fedcadf87ae3b21987fca2 Reviewed-by: Edward Welbourne --- src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp | 2 +- tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp b/src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp index 8533802a5a..2aa81f68a3 100644 --- a/src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp +++ b/src/quickcontrols/material/impl/qquickmaterialplaceholdertext.cpp @@ -146,7 +146,7 @@ qreal QQuickMaterialPlaceholderText::floatingTargetY() const // Outlined text fields have the placeaholder vertically centered // along the outline at the top. - return (-m_largestHeight / 2) + controlTopInset(textControl()); + return (-m_largestHeight / 2.0) + controlTopInset(textControl()); } /*! diff --git a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml index aac3bbd832..fb516ec669 100644 --- a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml +++ b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml @@ -1070,7 +1070,7 @@ TestCase { // The placeholder text should always float at a fixed position at the top // when text has been set, even when it's in a Flickable. flickable.contentY = -50 - compare(placeholderTextItem.y, -Math.floor(placeholderTextItem.largestHeight / 2)) + compare(placeholderTextItem.y, -placeholderTextItem.largestHeight / 2) flickable.contentY = 0 // When the text is cleared, it shouldn't float. -- cgit v1.2.1