Remove Q_ASSERT from qabstractxmlnodemodel test
authorJason McDonald <jason.mcdonald@nokia.com>
Fri, 6 May 2011 04:08:10 +0000 (14:08 +1000)
committerRohan McGovern <rohan.mcgovern@nokia.com>
Wed, 18 May 2011 01:04:38 +0000 (11:04 +1000)
Instead of aborting in debug builds and failing silently in release
builds, print a meaningful warning message into the test output and
return a null QVariant.

Change-Id: Idcd70f5cb01528b522d84e391f6f8692a189f420
Task-number: QTBUG-17582
Reviewed-by: Rohan McGovern
(cherry picked from commit a0496d1db09dfaa6a2b31a5c23e154de7b4a2eb7)

tests/auto/qabstractxmlnodemodel/LoadingModel.cpp

index 01d3164..2ce9466 100644 (file)
@@ -129,8 +129,11 @@ QVariant LoadingModel::typedValue(const QXmlNodeModelIndex &ni) const
 {
     const Node *const internal = toInternal(ni);
 
-    Q_ASSERT(internal->kind == QXmlNodeModelIndex::Attribute
-             || internal->kind == QXmlNodeModelIndex::Element);
+    if (internal->kind != QXmlNodeModelIndex::Attribute
+        && internal->kind != QXmlNodeModelIndex::Element) {
+        qWarning("%s: node must be an attribute or element", Q_FUNC_INFO);
+        return QVariant();
+    }
 
     return internal->value;
 }