Have the query parser directly return a shared_ptr and consequent simplifications

This commit is contained in:
Jean-Francois Dockes
2020-12-13 15:47:14 +01:00
parent 3417351bfb
commit 93f96ef68b
7 changed files with 29 additions and 35 deletions
+3 -3
View File
@@ -330,10 +330,10 @@ void SpellW::showStats()
it != allmimetypes.end(); it++) {
string reason;
string q = string("mime:") + *it;
Rcl::SearchData *sd = wasaStringToRcl(theconfig, "", q, reason);
std::shared_ptr<Rcl::SearchData> rq(sd);
std::shared_ptr<Rcl::SearchData> sd =
wasaStringToRcl(theconfig, "", q, reason);
Rcl::Query query(rcldb.get());
if (!query.setQuery(rq)) {
if (!query.setQuery(sd)) {
LOGERR("Query setup failed: " << (query.getReason()) << "" );
return;
}
+5 -6
View File
@@ -495,7 +495,7 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
xml << " <T>" << base64_encode(u8) << "</T>\n";
SSearchType tp = (SSearchType)searchTypCMB->currentIndex();
Rcl::SearchData *sdata = 0;
std::shared_ptr<Rcl::SearchData> sdata;
if (tp == SST_LANG) {
xml << " <SM>QL</SM>\n";
@@ -509,14 +509,14 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
} else {
sdata = wasaStringToRcl(theconfig, stemlang, u8, reason);
}
if (sdata == 0) {
if (!sdata) {
QMessageBox::warning(0, "Recoll", tr("Bad query string") + ": " +
QString::fromUtf8(reason.c_str()));
return false;
}
} else {
sdata = new Rcl::SearchData(Rcl::SCLT_OR, stemlang);
if (sdata == 0) {
sdata = std::make_shared<Rcl::SearchData>(Rcl::SCLT_OR, stemlang);
if (!sdata) {
QMessageBox::warning(0, "Recoll", tr("Out of memory"));
return false;
}
@@ -554,9 +554,8 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
m_xml = xml.str();
LOGDEB("SSearch::startSimpleSearch:xml:[" << m_xml << "]\n");
std::shared_ptr<Rcl::SearchData> rsdata(sdata);
emit setDescription(u8s2qs(u8));
emit startSearch(rsdata, true);
emit startSearch(sdata, true);
return true;
}