From 7dee82154f81dd6e65f1455629649c4e50fac7dd Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Sun, 12 May 2013 22:33:37 +0200 Subject: [PATCH 1/8] Using a file name clause in advanced search crashed the GUI because of a bad dynamic cast in the history management code --- src/rcldb/searchdata.h | 13 ++++++---- src/rcldb/searchdataxml.cpp | 52 +++++++++++++++++++++++-------------- website/BUGS.html | 2 ++ website/release-1.19.html | 5 +++- 4 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/rcldb/searchdata.h b/src/rcldb/searchdata.h index 4c10f3d0..f9d3154b 100644 --- a/src/rcldb/searchdata.h +++ b/src/rcldb/searchdata.h @@ -315,6 +315,12 @@ public: m_haveWildCards = (txt.find_first_of(cstr_minwilds) != std::string::npos); } + SearchDataClauseSimple(const std::string& txt, SClType tp) + : SearchDataClause(tp), m_text(txt), m_curcl(0) + { + m_haveWildCards = + (txt.find_first_of(cstr_minwilds) != std::string::npos); + } virtual ~SearchDataClauseSimple() { @@ -365,10 +371,10 @@ protected: * field, especially for file names, because this makes searches for * "*xx" much faster (no need to scan the whole main index). */ -class SearchDataClauseFilename : public SearchDataClause { +class SearchDataClauseFilename : public SearchDataClauseSimple { public: SearchDataClauseFilename(const std::string& txt) - : SearchDataClause(SCLT_FILENAME), m_text(txt) + : SearchDataClauseSimple(txt, SCLT_FILENAME) { // File name searches don't count when looking for wild cards. m_haveWildCards = false; @@ -383,9 +389,6 @@ public: } virtual bool toNativeQuery(Rcl::Db &, void *); - -protected: - std::string m_text; }; diff --git a/src/rcldb/searchdataxml.cpp b/src/rcldb/searchdataxml.cpp index f2d90641..72b3b9e5 100644 --- a/src/rcldb/searchdataxml.cpp +++ b/src/rcldb/searchdataxml.cpp @@ -56,18 +56,20 @@ string SearchData::asXML() // Clause list os << "" << endl; + + // List conjunction: default is AND, else print it. if (m_tp != SCLT_AND) os << "" << tpToString(m_tp) << "" << endl; + for (unsigned int i = 0; i < m_query.size(); i++) { SearchDataClause *c = m_query[i]; if (c->getTp() == SCLT_SUB) { LOGERR(("SearchData::asXML: can't do subclauses !\n")); continue; } - if (c->getexclude()) - os << "" << endl; if (c->getTp() == SCLT_PATH) { - // Keep these apart, for compat with the older history format + // Keep these apart, for compat with the older history format. NEG + // is ignored here, we have 2 different tags instead. SearchDataClausePath *cl = dynamic_cast(c); if (cl->getexclude()) { @@ -76,24 +78,36 @@ string SearchData::asXML() os << "" << base64_encode(cl->gettext()) << "" << endl; } continue; - } + } else { - SearchDataClauseSimple *cl = - dynamic_cast(c); - os << "" << endl; - if (cl->getTp() != SCLT_AND) { - os << "" << tpToString(cl->getTp()) << "" << endl; + os << "" << endl; + + if (c->getexclude()) + os << "" << endl; + + if (c->getTp() != SCLT_AND) { + os << "" << tpToString(c->getTp()) << "" << endl; + } + if (c->getTp() == SCLT_FILENAME) { + SearchDataClauseFilename *cl = + dynamic_cast(c); + os << "" << base64_encode(cl->gettext()) << "" << endl; + } else { + SearchDataClauseSimple *cl = + dynamic_cast(c); + if (!cl->getfield().empty()) { + os << "" << base64_encode(cl->getfield()) << "" << + endl; + } + os << "" << base64_encode(cl->gettext()) << "" << endl; + if (cl->getTp() == SCLT_NEAR || cl->getTp() == SCLT_PHRASE) { + SearchDataClauseDist *cld = + dynamic_cast(cl); + os << "" << cld->getslack() << "" << endl; + } + } + os << "" << endl; } - if (cl->getTp() != SCLT_FILENAME && !cl->getfield().empty()) { - os << "" << base64_encode(cl->getfield()) << "" << endl; - } - os << "" << base64_encode(cl->gettext()) << "" << endl; - if (cl->getTp() == SCLT_NEAR || cl->getTp() == SCLT_PHRASE) { - SearchDataClauseDist *cld = - dynamic_cast(cl); - os << "" << cld->getslack() << "" << endl; - } - os << "" << endl; } os << "" << endl; diff --git a/website/BUGS.html b/website/BUGS.html index 14bd7e40..15d1a36a 100644 --- a/website/BUGS.html +++ b/website/BUGS.html @@ -31,6 +31,8 @@ versions.

recoll 1.19.0