diff options
16 files changed, 58 insertions, 51 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 623e3df..e3ce70e 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -228,10 +228,10 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop, } break; case QMetaType::Float: - if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected")); + if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected")); break; case QVariant::Double: - if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected")); + if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: number expected")); break; case QVariant::Color: { diff --git a/src/declarative/qml/qdeclarativedom.cpp b/src/declarative/qml/qdeclarativedom.cpp index a3cddb5..5b30bde 100644 --- a/src/declarative/qml/qdeclarativedom.cpp +++ b/src/declarative/qml/qdeclarativedom.cpp @@ -493,7 +493,7 @@ int QDeclarativeDomDynamicProperty::propertyType() const return QMetaType::type("int"); case QDeclarativeParser::Object::DynamicProperty::Real: - return QMetaType::type("double"); + return sizeof(qreal) == sizeof(double) ? QMetaType::type("double") : QMetaType::type("float"); case QDeclarativeParser::Object::DynamicProperty::String: return QMetaType::type("QString"); diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index c32cab6..153e2be 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -1152,7 +1152,7 @@ bool QDeclarativeMetaType::copy(int type, void *data, const void *copy) *static_cast<float *>(data) = float(0); return true; case QMetaType::Double: - *static_cast<double *>(data) = double(); + *static_cast<double *>(data) = double(0); return true; case QMetaType::QChar: *static_cast<NS(QChar) *>(data) = NS(QChar)(); diff --git a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp index a965ef3..3e80c2c 100644 --- a/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp +++ b/tests/auto/declarative/qdeclarativeanimations/tst_qdeclarativeanimations.cpp @@ -310,7 +310,7 @@ void tst_qdeclarativeanimations::badTypes() c.create(); QVERIFY(c.errors().count() == 1); - QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: double expected")); + QCOMPARE(c.errors().at(0).description(), QLatin1String("Invalid property assignment: number expected")); } //make sure we get a compiler error diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml index db7f2b5..2c79729 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.2.qml @@ -7,7 +7,7 @@ MyTypeObject { uintProperty: if(1) 10 intProperty: if(1) -19 realProperty: if(1) 23.2 - doubleProperty: if(1) -19.7 + doubleProperty: if(1) -19.75 floatProperty: if(1) 8.5 colorProperty: if(1) "red" dateProperty: if(1) "1982-11-25" diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml index 72ae865..1cd78a5 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml +++ b/tests/auto/declarative/qdeclarativeecmascript/data/assignBasicTypes.qml @@ -9,7 +9,7 @@ MyTypeObject { uintProperty = 10 intProperty = -19 realProperty = 23.2 - doubleProperty = -19.7 + doubleProperty = -19.75 floatProperty = 8.5 colorProperty = "red" dateProperty = "1982-11-25" diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h index 849879e..19bfd37 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.h +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.h @@ -572,7 +572,7 @@ public: Q_INVOKABLE void method_NoArgs() { invoke(0); } Q_INVOKABLE int method_NoArgs_int() { invoke(1); return 6; } - Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.7; } + Q_INVOKABLE qreal method_NoArgs_real() { invoke(2); return 19.75; } Q_INVOKABLE QPointF method_NoArgs_QPointF() { invoke(3); return QPointF(123, 4.5); } Q_INVOKABLE QObject *method_NoArgs_QObject() { invoke(4); return this; } Q_INVOKABLE MyInvokableObject *method_NoArgs_unknown() { invoke(5); return this; } diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 43900ae..a6d2dac 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -179,7 +179,7 @@ void tst_qdeclarativeecmascript::assignBasicTypes() QCOMPARE(object->uintProperty(), uint(10)); QCOMPARE(object->intProperty(), -19); QCOMPARE((float)object->realProperty(), float(23.2)); - QCOMPARE((float)object->doubleProperty(), float(-19.7)); + QCOMPARE((float)object->doubleProperty(), float(-19.75)); QCOMPARE((float)object->floatProperty(), float(8.5)); QCOMPARE(object->colorProperty(), QColor("red")); QCOMPARE(object->dateProperty(), QDate(1982, 11, 25)); @@ -207,7 +207,7 @@ void tst_qdeclarativeecmascript::assignBasicTypes() QCOMPARE(object->uintProperty(), uint(10)); QCOMPARE(object->intProperty(), -19); QCOMPARE((float)object->realProperty(), float(23.2)); - QCOMPARE((float)object->doubleProperty(), float(-19.7)); + QCOMPARE((float)object->doubleProperty(), float(-19.75)); QCOMPARE((float)object->floatProperty(), float(8.5)); QCOMPARE(object->colorProperty(), QColor("red")); QCOMPARE(object->dateProperty(), QDate(1982, 11, 25)); @@ -280,8 +280,8 @@ void tst_qdeclarativeecmascript::signalAssignment() MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create()); QVERIFY(object != 0); QCOMPARE(object->string(), QString()); - emit object->argumentSignal(19, "Hello world!", 10.3); - QCOMPARE(object->string(), QString("pass 19 Hello world! 10.3")); + emit object->argumentSignal(19, "Hello world!", 10.25); + QCOMPARE(object->string(), QString("pass 19 Hello world! 10.25")); } } @@ -1387,7 +1387,7 @@ void tst_qdeclarativeecmascript::callQtInvokables() QCOMPARE(o.actuals().count(), 0); o.reset(); - QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.7))); + QVERIFY(engine->evaluate("object.method_NoArgs_real()").strictlyEquals(QScriptValue(engine, 19.75))); QCOMPARE(o.error(), false); QCOMPARE(o.invoked(), 2); QCOMPARE(o.actuals().count(), 0); @@ -1818,7 +1818,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toBool(), true); delete object; @@ -1831,7 +1831,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toBool(), true); delete object; @@ -1844,7 +1844,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toBool(), true); delete object; @@ -1857,7 +1857,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->methodCalled(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->methodCalled(), true); delete object; @@ -1870,7 +1870,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->methodCalled(), false); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->methodCalled(), true); delete object; @@ -1883,7 +1883,7 @@ void tst_qdeclarativeecmascript::scriptConnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); delete object; @@ -1899,13 +1899,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); delete object; @@ -1918,13 +1918,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); delete object; @@ -1937,13 +1937,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 3); delete object; @@ -1955,13 +1955,13 @@ void tst_qdeclarativeecmascript::scriptDisconnect() QVERIFY(object != 0); QCOMPARE(object->property("test").toInt(), 0); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 1); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 2); emit object->basicSignal(); QCOMPARE(object->property("test").toInt(), 2); - emit object->argumentSignal(19, "Hello world!", 10.3); + emit object->argumentSignal(19, "Hello world!", 10.25); QCOMPARE(object->property("test").toInt(), 3); delete object; diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-float.png b/tests/auto/declarative/qdeclarativeimage/data/heart-float.png Binary files differnew file mode 100644 index 0000000..65bd89f --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/heart-float.png diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-float.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-float.png Binary files differnew file mode 100644 index 0000000..786e75d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeimage/data/heart200-float.png diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index c09f7fc..ace6712 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -124,8 +124,8 @@ void tst_qdeclarativeimage::noSource() void tst_qdeclarativeimage::imageSource_data() { QTest::addColumn<QString>("source"); - QTest::addColumn<qreal>("width"); - QTest::addColumn<qreal>("height"); + QTest::addColumn<double>("width"); + QTest::addColumn<double>("height"); QTest::addColumn<bool>("remote"); QTest::addColumn<bool>("async"); QTest::addColumn<QString>("error"); @@ -146,8 +146,8 @@ void tst_qdeclarativeimage::imageSource_data() void tst_qdeclarativeimage::imageSource() { QFETCH(QString, source); - QFETCH(qreal, width); - QFETCH(qreal, height); + QFETCH(double, width); + QFETCH(double, height); QFETCH(bool, remote); QFETCH(bool, async); QFETCH(QString, error); @@ -178,8 +178,8 @@ void tst_qdeclarativeimage::imageSource() if (error.isEmpty()) { TRY_WAIT(obj->status() == QDeclarativeImage::Ready); - QCOMPARE(obj->width(), width); - QCOMPARE(obj->height(), height); + QCOMPARE(obj->width(), qreal(width)); + QCOMPARE(obj->height(), qreal(height)); QCOMPARE(obj->fillMode(), QDeclarativeImage::Stretch); QCOMPARE(obj->progress(), 1.0); } else { @@ -308,7 +308,10 @@ void tst_qdeclarativeimage::svg() #elif defined(Q_OS_WIN32) QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-win32.png")); #else - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); + if (sizeof(qreal) == sizeof(double)) + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart.png")); + else + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart-float.png")); #endif obj->setSourceSize(QSize(200,200)); @@ -322,7 +325,10 @@ void tst_qdeclarativeimage::svg() #elif defined(Q_OS_WIN32) QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-win32.png")); #else - QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); + if (sizeof(qreal) == sizeof(double)) + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200.png")); + else + QCOMPARE(obj->pixmap(), QPixmap(SRCDIR "/data/heart200-float.png")); #endif delete obj; } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt index 886da55..6e11786 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/nestedErrors.errors.txt @@ -1,2 +1,2 @@ 4:5:Unable to create type NestedErrorsType -4:8:Invalid property assignment: double expected +4:8:Invalid property assignment: number expected diff --git a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt index d0a0b00..d2b8c54 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/wrongType.6.errors.txt @@ -1 +1 @@ -3:19:Invalid property assignment: double expected +3:19:Invalid property assignment: number expected diff --git a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp index 8964f8a..b06ad7c 100644 --- a/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp +++ b/tests/auto/declarative/qdeclarativemetatype/tst_qdeclarativemetatype.cpp @@ -124,6 +124,7 @@ QML_DECLARE_TYPE(ValueInterceptorTestType); { \ cpptype v = (value); cpptype v2 = (value); \ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, 0)); \ + QCOMPARE((cpptype)(v),(cpptype)(defaultvalue)); \ QVERIFY(v == (defaultvalue)); \ QVERIFY(QDeclarativeMetaType::copy(QMetaType:: metatype, &v, &v2)); \ QVERIFY(v == (value)); \ @@ -273,7 +274,7 @@ void tst_qdeclarativemetatype::copy() QWidget widgetValue; COPY_TEST(QObject *, QObjectStar, &objectValue, 0); COPY_TEST(QWidget *, QWidgetStar, &widgetValue, 0); - COPY_TEST(qreal, QReal, 10.2, 0); + COPY_TEST(qreal, QReal, 10.5, 0); { QVariant tv = QVariant::fromValue(QVariant(10)); diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index 81334f2..a4819f3 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -141,8 +141,8 @@ void tst_qdeclarativevaluetypes::pointf() MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QCOMPARE(object->property("p_x").toDouble(), 11.3); - QCOMPARE(object->property("p_y").toDouble(), -10.9); + QCOMPARE(float(object->property("p_x").toDouble()), float(11.3)); + QCOMPARE(float(object->property("p_y").toDouble()), float(-10.9)); QCOMPARE(object->property("copy"), QVariant(QPointF(11.3, -10.9))); delete object; @@ -191,8 +191,8 @@ void tst_qdeclarativevaluetypes::sizef() MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QCOMPARE(object->property("s_width").toDouble(), 0.1); - QCOMPARE(object->property("s_height").toDouble(), 100923.2); + QCOMPARE(float(object->property("s_width").toDouble()), float(0.1)); + QCOMPARE(float(object->property("s_height").toDouble()), float(100923.2)); QCOMPARE(object->property("copy"), QVariant(QSizeF(0.1, 100923.2))); delete object; @@ -287,10 +287,10 @@ void tst_qdeclarativevaluetypes::rectf() MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); QVERIFY(object != 0); - QCOMPARE(object->property("r_x").toDouble(), 103.8); - QCOMPARE(object->property("r_y").toDouble(), 99.2); - QCOMPARE(object->property("r_width").toDouble(), 88.1); - QCOMPARE(object->property("r_height").toDouble(), 77.6); + QCOMPARE(float(object->property("r_x").toDouble()), float(103.8)); + QCOMPARE(float(object->property("r_y").toDouble()), float(99.2)); + QCOMPARE(float(object->property("r_width").toDouble()), float(88.1)); + QCOMPARE(float(object->property("r_height").toDouble()), float(77.6)); QCOMPARE(object->property("copy"), QVariant(QRectF(103.8, 99.2, 88.1, 77.6))); delete object; diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index 8e98874..3140265 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -134,7 +134,7 @@ void tst_QDeclarativeWorkerScript::messaging_data() QTest::newRow("invalid") << QVariant(); QTest::newRow("bool") << qVariantFromValue(true); QTest::newRow("int") << qVariantFromValue(1001); - QTest::newRow("real") << qVariantFromValue(10334.323); + QTest::newRow("real") << qVariantFromValue(10334.375); QTest::newRow("string") << qVariantFromValue(QString("More cheeeese, Gromit!")); QTest::newRow("variant list") << qVariantFromValue((QVariantList() << "a" << "b" << "c")); } |