aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/common/qjsnumbercoercion.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/qml/common/qjsnumbercoercion.h b/src/qml/common/qjsnumbercoercion.h
index 51dbe6beb5..2517442bb6 100644
--- a/src/qml/common/qjsnumbercoercion.h
+++ b/src/qml/common/qjsnumbercoercion.h
@@ -49,9 +49,13 @@ class QJSNumberCoercion
{
public:
static constexpr int toInteger(double d) {
- int i = static_cast<int>(d);
+ if (!equals(d, d))
+ return 0;
+
+ const int i = static_cast<int>(d);
if (equals(i, d))
return i;
+
return QJSNumberCoercion(d).toInteger();
}