GUI: avoid writing qt/recoll settings if we did not read them first. Some configuration error cases (unexisting recoll config dir) could result into settings being erased

This commit is contained in:
Jean-Francois Dockes 2011-12-01 17:16:30 +01:00
parent fdfb77bf5b
commit 4e2266495f

View File

@ -51,6 +51,11 @@ RclConfig *theconfig;
RclConfig *thestableconfig; RclConfig *thestableconfig;
PTMutexInit thestableconfiglock; PTMutexInit thestableconfiglock;
// To avoid writing settings if we stopped before reading them (else
// some kinds of errors would reset the qt/recoll settings to
// defaults)
static bool havereadsettings;
void snapshotConfig() void snapshotConfig()
{ {
PTMutexLocker locker(thestableconfiglock); PTMutexLocker locker(thestableconfiglock);
@ -140,8 +145,10 @@ bool getStemLangs(list<string>& langs)
static void recollCleanup() static void recollCleanup()
{ {
LOGDEB(("recollCleanup: writing settings\n")); if (havereadsettings) {
rwSettings(true); LOGDEB(("recollCleanup: writing settings\n"));
rwSettings(true);
}
LOGDEB2(("recollCleanup: closing database\n")); LOGDEB2(("recollCleanup: closing database\n"));
deleteZ(rcldb); deleteZ(rcldb);
deleteZ(theconfig); deleteZ(theconfig);
@ -305,6 +312,7 @@ int main(int argc, char **argv)
// fprintf(stderr, "History done\n"); // fprintf(stderr, "History done\n");
rwSettings(false); rwSettings(false);
havereadsettings = true;
// fprintf(stderr, "Settings done\n"); // fprintf(stderr, "Settings done\n");