Fix bug which was causing the doubling of a non standard (extended) advanced search clauses list every time the prefs were read after the first time during a session
This commit is contained in:
parent
d87d410f11
commit
4671f5ea25
@ -87,26 +87,40 @@ void rwSettings(bool writing)
|
|||||||
SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Int, 3);
|
SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Int, 3);
|
||||||
SETTING_RW(prefs.startWithAdvSearchOpen,
|
SETTING_RW(prefs.startWithAdvSearchOpen,
|
||||||
"/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
|
"/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
|
||||||
SETTING_RW(prefs.previewHtml,
|
SETTING_RW(prefs.previewHtml, "/Recoll/prefs/previewHtml", Bool, true);
|
||||||
"/Recoll/prefs/previewHtml", Bool, true);
|
|
||||||
|
|
||||||
QString advSearchClauses;
|
QString advSearchClauses;
|
||||||
QString ascdflt;
|
const int maxclauselistsize = 20;
|
||||||
if (writing) {
|
if (writing) {
|
||||||
for (vector<int>::iterator it = prefs.advSearchClauses.begin();
|
// Limit clause list size to non-absurd size
|
||||||
it != prefs.advSearchClauses.end(); it++) {
|
if (prefs.advSearchClauses.size() > maxclauselistsize) {
|
||||||
|
prefs.advSearchClauses.resize(maxclauselistsize);
|
||||||
|
}
|
||||||
|
for (auto clause : prefs.advSearchClauses) {
|
||||||
char buf[20];
|
char buf[20];
|
||||||
sprintf(buf, "%d ", *it);
|
sprintf(buf, "%d ", clause);
|
||||||
advSearchClauses += QString::fromUtf8(buf);
|
advSearchClauses += QString::fromUtf8(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QString ascdflt;
|
||||||
SETTING_RW(advSearchClauses, "/Recoll/prefs/adv/clauseList", String, ascdflt);
|
SETTING_RW(advSearchClauses, "/Recoll/prefs/adv/clauseList", String, ascdflt);
|
||||||
if (!writing) {
|
if (!writing) {
|
||||||
list<string> clauses;
|
vector<string> clauses;
|
||||||
stringToStrings((const char *)advSearchClauses.toUtf8(), clauses);
|
stringToStrings(qs2utf8s(advSearchClauses), clauses);
|
||||||
for (list<string>::iterator it = clauses.begin();
|
// There was a long-lurking bug where the clause list was
|
||||||
it != clauses.end(); it++) {
|
// growing to absurd sizes. The prefs.advSearchClauses clear()
|
||||||
prefs.advSearchClauses.push_back(atoi(it->c_str()));
|
// call was missing (ok with the now false initial assumption
|
||||||
|
// that the prefs were read once per session), which was
|
||||||
|
// causing a doubling of the size each time the prefs were
|
||||||
|
// read. Should be fixed, but in any case, limit the clause
|
||||||
|
// list to a non-absurd size.
|
||||||
|
if (clauses.size() > maxclauselistsize) {
|
||||||
|
clauses.resize(maxclauselistsize);
|
||||||
|
}
|
||||||
|
prefs.advSearchClauses.clear();
|
||||||
|
prefs.advSearchClauses.reserve(clauses.size());
|
||||||
|
for (auto clause : clauses) {
|
||||||
|
prefs.advSearchClauses.push_back(atoi(clause.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user