avoid spurious warning popups about stemming languages when index does not exist

This commit is contained in:
Jean-Francois Dockes 2013-06-08 09:42:23 +02:00
parent 6be1be6b6d
commit 4071618548
2 changed files with 22 additions and 11 deletions

View File

@ -128,15 +128,29 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
return true;
}
bool getStemLangs(vector<string>& langs)
// Retrieve the list currently active stemming languages. We try to
// get this from the db, as some may have been added from recollindex
// without changing the config. If this fails, use the config. This is
// used for setting up choice menus, not updating the configuration.
bool getStemLangs(vector<string>& vlangs)
{
// Try from db
string reason;
if (!maybeOpenDb(reason)) {
LOGERR(("getStemLangs: %s\n", reason.c_str()));
if (maybeOpenDb(reason)) {
vlangs = rcldb->getStemLangs();
LOGDEB0(("getStemLangs: from index: %s\n",
stringsToString(vlangs).c_str()));
return true;
} else {
// Cant get the langs from the index. Maybe it just does not
// exist yet. So get them from the config
string slangs;
if (theconfig->getConfParam("indexstemminglanguages", slangs)) {
stringToStrings(slangs, vlangs);
return true;
}
return false;
}
langs = rcldb->getStemLangs();
return true;
}
static void recollCleanup()

View File

@ -137,17 +137,14 @@ void RclMain::init()
// db not open yet (the case where it does not even exist makes
// things complicated). So get the languages from the config
// instead
string slangs;
list<string> langs;
if (theconfig->getConfParam("indexstemminglanguages", slangs)) {
stringToStrings(slangs, langs);
} else {
vector<string> langs;
if (!getStemLangs(langs)) {
QMessageBox::warning(0, "Recoll",
tr("error retrieving stemming languages"));
}
QAction *curid = prefs.queryStemLang == "ALL" ? m_idAllStem : m_idNoStem;
QAction *id;
for (list<string>::const_iterator it = langs.begin();
for (vector<string>::const_iterator it = langs.begin();
it != langs.end(); it++) {
QString qlang = QString::fromAscii(it->c_str(), it->length());
id = preferencesMenu->addAction(qlang);