summaryrefslogtreecommitdiffstats
path: root/tests/auto/qxmlquery
diff options
context:
space:
mode:
authorAapo Haapanen <aapo.haapanen@nokia.com>2011-09-22 12:50:50 (GMT)
committerAapo Haapanen <aapo.haapanen@nokia.com>2011-09-23 12:19:08 (GMT)
commit00a3147f66688b71069989bbac406a00f6e8cf83 (patch)
tree29221eaa7b6021002e6ac0596a526a0c9fd8b800 /tests/auto/qxmlquery
parentb0fbf9dae591dc839e14a087c1d69189e3fe9461 (diff)
downloadQt-00a3147f66688b71069989bbac406a00f6e8cf83.zip
Qt-00a3147f66688b71069989bbac406a00f6e8cf83.tar.gz
Qt-00a3147f66688b71069989bbac406a00f6e8cf83.tar.bz2
Fix for QTBUG-18050: QXmlQuery crash
If QXmlQuery has a previous focus and an invalid xml is given in setFocus, the old focus must be cleared. Otherwise the query may be left in an inconsistent state. Task-number: QTBUG-18050 Reviewed-by: Miikka Heikkinen
Diffstat (limited to 'tests/auto/qxmlquery')
-rw-r--r--tests/auto/qxmlquery/tst_qxmlquery.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp
index e443720..51bb88e 100644
--- a/tests/auto/qxmlquery/tst_qxmlquery.cpp
+++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp
@@ -167,6 +167,7 @@ private Q_SLOTS:
void setFocusQString() const;
void setFocusQStringFailure() const;
void setFocusQStringSignature() const;
+ void setFocusQStringFailureAfterSucces() const;
void recompilationWithEvaluateToResultFailing() const;
void secondEvaluationWithEvaluateToResultFailing() const;
void recompilationWithEvaluateToReceiver() const;
@@ -1976,6 +1977,25 @@ void tst_QXmlQuery::setFocusQStringSignature() const
static_cast<bool>(query.setFocus(QString()));
}
+void tst_QXmlQuery::setFocusQStringFailureAfterSucces() const
+{
+ /* Test for QTBUG-18050. First call setFocus with a valid string,
+ * and then with an invalid string. evaluateTo should not crash. */
+ QXmlQuery query;
+ MessageSilencer silencer;
+ query.setMessageHandler(&silencer);
+
+ QVERIFY(query.setFocus(QLatin1String("<test>valid-input</test>")));
+ QVERIFY(!query.setFocus(QLatin1String("invalid-input")));
+
+ query.setQuery("/query");
+
+ QString output;
+ /* Last setFocus was with an invalid string, so evaluateTo should return
+ * false */
+ QVERIFY(!query.evaluateTo(&output));
+}
+
void tst_QXmlQuery::setFocusQIODeviceTriggerWarnings() const
{
/* A null pointer. */