Remove Q_ASSERT from qabstractxmlnodemodel test
authorJason McDonald <jason.mcdonald@nokia.com>
Thu, 5 May 2011 07:36:59 +0000 (17:36 +1000)
committerRohan McGovern <rohan.mcgovern@nokia.com>
Wed, 18 May 2011 01:04:38 +0000 (11:04 +1000)
When no content can be loaded to create the model, return a null model
(which will make the test fail gracefully) rather than aborting in a
debug build and failing silently in a release build.

Change-Id: I28f0bb92c617c8dafd1089d0b3dafcfef0c0da53
Task-number: QTBUG-17582
Reviewed-by: Rohan McGovern
(cherry picked from commit 416d45caa9feefe8337795adc4b93a8148d57a3a)

tests/auto/qabstractxmlnodemodel/LoadingModel.cpp

index 054fd69..cf85486 100644 (file)
@@ -53,7 +53,6 @@ LoadingModel::LoadingModel(const Node::Vector &content,
                            const QXmlNamePool &np) : QSimpleXmlNodeModel(np)
                                                    , m_nodes(content)
 {
-    Q_ASSERT(!content.isEmpty());
     /*
     foreach(const Node *n, content)
         qDebug() << "this:" << n
@@ -354,6 +353,11 @@ QAbstractXmlNodeModel::Ptr LoadingModel::create(const QXmlNamePool &np)
 {
     Loader loader(np);
     loader.load();
+    if (loader.m_result.isEmpty()) {
+        qWarning("%s: attempt to create model with no content", Q_FUNC_INFO);
+        return Ptr(0);
+    }
+
     return Ptr(new LoadingModel(loader.m_result, np));
 }
 #endif //QTEST_XMLPATTERNS