ptrans: reopen the db so that the new translations are used at once (no need for restart)
This commit is contained in:
parent
7cd6f90554
commit
86020a6896
@ -92,14 +92,12 @@ void startManual(const string& helpindex)
|
|||||||
|
|
||||||
bool maybeOpenDb(string &reason, bool force, bool *maindberror)
|
bool maybeOpenDb(string &reason, bool force, bool *maindberror)
|
||||||
{
|
{
|
||||||
LOGDEB2("maybeOpenDb: force " << (force) << "\n" );
|
LOGDEB2("maybeOpenDb: force " << force << "\n");
|
||||||
if (!rcldb) {
|
|
||||||
reason = "Internal error: db not created";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (force)
|
if (force) {
|
||||||
rcldb->close();
|
delete rcldb;
|
||||||
|
rcldb = new Rcl::Db(theconfig);
|
||||||
|
}
|
||||||
rcldb->rmQueryDb("");
|
rcldb->rmQueryDb("");
|
||||||
for (const auto& dbdir : prefs.activeExtraDbs) {
|
for (const auto& dbdir : prefs.activeExtraDbs) {
|
||||||
LOGDEB("main: adding [" << dbdir << "]\n");
|
LOGDEB("main: adding [" << dbdir << "]\n");
|
||||||
@ -129,7 +127,7 @@ bool getStemLangs(vector<string>& vlangs)
|
|||||||
string reason;
|
string reason;
|
||||||
if (maybeOpenDb(reason)) {
|
if (maybeOpenDb(reason)) {
|
||||||
vlangs = rcldb->getStemLangs();
|
vlangs = rcldb->getStemLangs();
|
||||||
LOGDEB0("getStemLangs: from index: " << (stringsToString(vlangs)) << "\n" );
|
LOGDEB0("getStemLangs: from index: " << stringsToString(vlangs) <<"\n");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// Cant get the langs from the index. Maybe it just does not
|
// Cant get the langs from the index. Maybe it just does not
|
||||||
@ -375,8 +373,8 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
rcldb = new Rcl::Db(theconfig);
|
maybeOpenDb(reason);
|
||||||
|
|
||||||
mainWindow->show();
|
mainWindow->show();
|
||||||
QTimer::singleShot(0, mainWindow, SLOT(initDbOpen()));
|
QTimer::singleShot(0, mainWindow, SLOT(initDbOpen()));
|
||||||
|
|
||||||
|
|||||||
@ -99,6 +99,10 @@ void EditTrans::on_savePB_clicked()
|
|||||||
conftrans->set(from, to, m_dbdir);
|
conftrans->set(from, to, m_dbdir);
|
||||||
}
|
}
|
||||||
conftrans->holdWrites(false);
|
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();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user