From 029f98ee0176b34279e7cc944cca17f027fe5a0a Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 17 May 2010 11:26:51 +1000 Subject: ListModel::get() shouldn't print warnings for invalid indices since it returns undefined items for these cases anywyay. --- src/declarative/util/qdeclarativelistmodel.cpp | 5 +---- .../qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 14 ++++---------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 6223548..9a5c9de 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -537,10 +537,7 @@ void QDeclarativeListModel::append(const QScriptValue& valuemap) */ QScriptValue QDeclarativeListModel::get(int index) const { - // the internal flat/nested class takes care of return value for bad index - if (index >= count() || index < 0) - qmlInfo(this) << tr("get: index %1 out of range").arg(index); - + // the internal flat/nested class checks for bad index return m_flat ? m_flat->get(index) : m_nested->get(index); } diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index aed4781..26a12f0 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -184,8 +184,8 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("count") << "count" << 0 << ""; - QTest::newRow("get1") << "{get(0)}" << 0 << ": QML ListModel: get: index 0 out of range"; - QTest::newRow("get2") << "{get(-1)}" << 0 << ": QML ListModel: get: index -1 out of range"; + QTest::newRow("get1") << "{get(0)}" << 0 << ""; + QTest::newRow("get2") << "{get(-1)}" << 0 << ""; QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << ""; QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << ""; @@ -196,13 +196,13 @@ void tst_qdeclarativelistmodel::dynamic_data() QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << ""; QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << ""; - QTest::newRow("clear3") << "{append({'foo':123});clear();get(0).foo}" << 0 << ": QML ListModel: get: index 0 out of range"; + QTest::newRow("clear3") << "{append({'foo':123});clear()}" << 0 << ""; QTest::newRow("remove1") << "{append({'foo':123});remove(0);count}" << 0 << ""; QTest::newRow("remove2a") << "{append({'foo':123});append({'foo':456});remove(0);count}" << 1 << ""; QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << ""; QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << ""; - QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << ": QML ListModel: get: index 0 out of range"; + QTest::newRow("remove3") << "{append({'foo':123});remove(0)}" << 0 << ""; QTest::newRow("remove3a") << "{append({'foo':123});remove(-1);count}" << 1 << ": QML ListModel: remove: index -1 out of range"; QTest::newRow("remove4a") << "{remove(0)}" << 0 << ": QML ListModel: remove: index 0 out of range"; QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0);count}" << 0 << ": QML ListModel: remove: index 0 out of range"; @@ -328,12 +328,6 @@ void tst_qdeclarativelistmodel::dynamic_worker() if (QByteArray(QTest::currentDataTag()).startsWith("nested")) QTest::ignoreMessage(QtWarningMsg, ": QML ListModel: Cannot add nested list values when modifying or after modification from a worker script"); - if (QByteArray(QTest::currentDataTag()).startsWith("nested-append")) { - int callsToGet = script.count(QLatin1String(";get(")); - for (int i=0; i: QML ListModel: get: index 0 out of range"); - } - QVERIFY(QMetaObject::invokeMethod(item, "evalExpressionViaWorker", Q_ARG(QVariant, operations.mid(0, operations.length()-1)))); waitForWorker(item); -- cgit v0.12