From 4e2266495f7cd8a77fd9ad8c128f10fb4268fdec Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Thu, 1 Dec 2011 17:16:30 +0100 Subject: [PATCH] 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 --- src/qtgui/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index a0a79f56..26814e88 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -51,6 +51,11 @@ RclConfig *theconfig; RclConfig *thestableconfig; 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() { PTMutexLocker locker(thestableconfiglock); @@ -140,8 +145,10 @@ bool getStemLangs(list& langs) static void recollCleanup() { - LOGDEB(("recollCleanup: writing settings\n")); - rwSettings(true); + if (havereadsettings) { + LOGDEB(("recollCleanup: writing settings\n")); + rwSettings(true); + } LOGDEB2(("recollCleanup: closing database\n")); deleteZ(rcldb); deleteZ(theconfig); @@ -305,6 +312,7 @@ int main(int argc, char **argv) // fprintf(stderr, "History done\n"); rwSettings(false); + havereadsettings = true; // fprintf(stderr, "Settings done\n");