From 4071618548523a3f5b1a266d13a08f8511070a40 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Sat, 8 Jun 2013 09:42:23 +0200 Subject: [PATCH] avoid spurious warning popups about stemming languages when index does not exist --- src/qtgui/main.cpp | 24 +++++++++++++++++++----- src/qtgui/rclmain_w.cpp | 9 +++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 4c15a401..18d03a34 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -128,15 +128,29 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror) return true; } -bool getStemLangs(vector& 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& 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() diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 9b22e63d..f0095ec2 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -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 langs; - if (theconfig->getConfParam("indexstemminglanguages", slangs)) { - stringToStrings(slangs, langs); - } else { + vector 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::const_iterator it = langs.begin(); + for (vector::const_iterator it = langs.begin(); it != langs.end(); it++) { QString qlang = QString::fromAscii(it->c_str(), it->length()); id = preferencesMenu->addAction(qlang);