diff options
author | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2011-05-20 10:30:35 (GMT) |
---|---|---|
committer | Kim Motoyoshi Kalland <kim.kalland@nokia.com> | 2011-05-20 10:49:09 (GMT) |
commit | eedab65056a6898e5a6f6bd103bed53e6787d334 (patch) | |
tree | 2a2954f94a0e041da2fcec0d8083447e5c2989b4 | |
parent | 31e9c098f3c9321eebf1ac3e4c44a2d18d3816b8 (diff) | |
download | Qt-eedab65056a6898e5a6f6bd103bed53e6787d334.zip Qt-eedab65056a6898e5a6f6bd103bed53e6787d334.tar.gz Qt-eedab65056a6898e5a6f6bd103bed53e6787d334.tar.bz2 |
Fixed inconsistent behaviour in Qt.rect().
The QML function Qt.rect() used to return a null rectangle if
the width or height argument were negative. This was
inconsistent with Qt.size() and parsing a string of the type
"x,y,wxh" which do not check the width and height.
Reviewed-by: Samuel
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 3 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp | 2 |
2 files changed, 1 insertions, 4 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 9fde18c..1feaeb3 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1699,9 +1699,6 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine qsreal w = ctxt->argument(2).toNumber(); qsreal h = ctxt->argument(3).toNumber(); - if (w < 0 || h < 0) - return engine->nullValue(); - return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QRectF(x, y, w, h))); } diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 80d9d93..518be89 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -174,7 +174,7 @@ void tst_qdeclarativeqt::rect() QCOMPARE(qvariant_cast<QRectF>(object->property("test2")), QRectF(-10, 13, 100, 109.6)); QCOMPARE(qvariant_cast<QRectF>(object->property("test3")), QRectF()); QCOMPARE(qvariant_cast<QRectF>(object->property("test4")), QRectF()); - QCOMPARE(qvariant_cast<QRectF>(object->property("test5")), QRectF()); + QCOMPARE(qvariant_cast<QRectF>(object->property("test5")), QRectF(10, 13, 100, -109)); delete object; } |