diff --git a/examples/xmlpatterns/filetree/mainwindow.cpp b/examples/xmlpatterns/filetree/mainwindow.cpp
index 83c3ebf9eced0c0c03b71bb96c0eb4045078553a..3116305d698a822d400f76a11d2ed92a463b564a 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);