From 4f2cdeb49abbfdc19fabdef4770abf740ee22460 Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Tue, 28 May 2013 19:09:18 +0000 Subject: [PATCH] Only use result if we find a match --- context/wikipediaengine.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/context/wikipediaengine.cpp b/context/wikipediaengine.cpp index 4f86030a5..e4f1da391 100644 --- a/context/wikipediaengine.cpp +++ b/context/wikipediaengine.cpp @@ -34,7 +34,9 @@ #include //#define DBUG qWarning() << "WikipediaEngine" +#ifndef DBUG #define DBUG qDebug() +#endif static const char * constModeProperty="mode"; static const char * constRedirectsProperty="redirects"; @@ -480,7 +482,12 @@ void WikipediaEngine::getPage(const QStringList &query, Mode mode, const QString } // TODO: If we fail to find a match, prompt user??? - const QString title=titles.takeAt(-1==index ? 0 : index); + if (-1==index) { + DBUG << __FUNCTION__ << "Failed to find match"; + emit searchResult(QString(), QString()); + return; + } + const QString title=titles.takeAt(index); if (QLatin1String("List of CJK Unified Ideographs")==title) { DBUG << __FUNCTION__ << "Unicode list?";