From b2b97badcf0f4082c03b64873871e885daeb4f5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Topi=20Reini=C3=B6?= Date: Wed, 4 Jul 2012 13:38:58 +0200 Subject: [PATCH] Qt XML Patterns File System Example: Do not bind to a null node index Adds a check for validity of the file node index before running an XQuery. In evaluateResult(), QXmlQuery binds to a QXmlNodeModelIndex variable without checking if it's valid. This causes an assert to trigger if the default directory that the example tries to open does not exist. In this case, m_fileNode has the default (null) value when evaluateResult() is invoked on QComboBox::currentIndexChanged() signal. Task-number: QTBUG-26081 Change-Id: I03c39939b57fcf658527ce3110fdc30d204de520 Reviewed-by: Friedemann Kleint --- examples/xmlpatterns/filetree/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/xmlpatterns/filetree/mainwindow.cpp b/examples/xmlpatterns/filetree/mainwindow.cpp index 83c3ebf..3116305 100644 --- a/examples/xmlpatterns/filetree/mainwindow.cpp +++ b/examples/xmlpatterns/filetree/mainwindow.cpp @@ -94,7 +94,7 @@ void MainWindow::on_queryBox_currentIndexChanged() //! [3] void MainWindow::evaluateResult() { - if (queryBox->currentText().isEmpty()) + if (queryBox->currentText().isEmpty() || m_fileNode.isNull()) return; QXmlQuery query(m_namePool); -- 2.7.4