ptrans: reopen the db so that the new translations are used at once (no need for restart)

This commit is contained in:
Jean-Francois Dockes 2019-02-04 17:24:00 +01:00
parent 7cd6f90554
commit 86020a6896
2 changed files with 12 additions and 10 deletions

View File

@ -92,14 +92,12 @@ void startManual(const string& helpindex)
bool maybeOpenDb(string &reason, bool force, bool *maindberror)
{
LOGDEB2("maybeOpenDb: force " << (force) << "\n" );
if (!rcldb) {
reason = "Internal error: db not created";
return false;
}
LOGDEB2("maybeOpenDb: force " << force << "\n");
if (force)
rcldb->close();
if (force) {
delete rcldb;
rcldb = new Rcl::Db(theconfig);
}
rcldb->rmQueryDb("");
for (const auto& dbdir : prefs.activeExtraDbs) {
LOGDEB("main: adding [" << dbdir << "]\n");
@ -129,7 +127,7 @@ bool getStemLangs(vector<string>& vlangs)
string reason;
if (maybeOpenDb(reason)) {
vlangs = rcldb->getStemLangs();
LOGDEB0("getStemLangs: from index: " << (stringsToString(vlangs)) << "\n" );
LOGDEB0("getStemLangs: from index: " << stringsToString(vlangs) <<"\n");
return true;
} else {
// Cant get the langs from the index. Maybe it just does not
@ -375,8 +373,8 @@ int main(int argc, char **argv)
exit(1);
}
rcldb = new Rcl::Db(theconfig);
maybeOpenDb(reason);
mainWindow->show();
QTimer::singleShot(0, mainWindow, SLOT(initDbOpen()));

View File

@ -99,6 +99,10 @@ void EditTrans::on_savePB_clicked()
conftrans->set(from, to, m_dbdir);
}
conftrans->holdWrites(false);
// The rcldb does not use the same configuration object, but a
// copy. Force a reopen, this is quick.
string reason;
maybeOpenDb(reason, true);
close();
}