From f2ce709a15dd18e3dd9949c2720c16a6ee4b7346 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Sun, 5 Apr 2015 09:08:55 +0200 Subject: [PATCH] Used to write settings in the exit handler, do it earlier because it crashes qt5 --- src/qtgui/guiutils.cpp | 9 +++++++++ src/qtgui/main.cpp | 10 ---------- src/qtgui/rclmain_w.cpp | 2 ++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 2fbba1c8..e00c67b4 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -64,9 +64,16 @@ PrefsPack prefs; * structure during program execution and saved to disk using the QT * settings mechanism */ +/* Remember if settings were actually read (to avoid writing them if + * we stopped before reading them (else some kinds of errors would reset + * the qt/recoll settings to defaults) */ +static bool havereadsettings; + void rwSettings(bool writing) { LOGDEB1(("rwSettings: write %d\n", int(writing))); + if (writing && !havereadsettings) + return; QSettings settings("Recoll.org", "recoll"); SETTING_RW(prefs.mainwidth, "/Recoll/geometry/width", Int, 0); SETTING_RW(prefs.mainheight, "/Recoll/geometry/height", Int, 0); @@ -383,6 +390,8 @@ void rwSettings(bool writing) for (list::iterator it = tl.begin(); it != tl.end(); it++) prefs.asearchSubdirHist.push_front(QString::fromUtf8(it->c_str())); } + if (!writing) + havereadsettings = true; } string PrefsPack::stemlang() diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index d21054cb..00efbbba 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -52,11 +52,6 @@ extern RclConfig *theconfig; -// 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; - PTMutexInit thetempfileslock; static vector o_tempfiles; /* Keep an array of temporary files for deletion at exit. It happens that we @@ -155,10 +150,6 @@ bool getStemLangs(vector& vlangs) static void recollCleanup() { - if (havereadsettings) { - LOGDEB(("recollCleanup: writing settings\n")); - rwSettings(true); - } LOGDEB2(("recollCleanup: closing database\n")); deleteZ(rcldb); deleteZ(theconfig); @@ -349,7 +340,6 @@ int main(int argc, char **argv) // fprintf(stderr, "History done\n"); rwSettings(false); - havereadsettings = true; // fprintf(stderr, "Settings done\n"); if (!prefs.qssFile.isEmpty()) { diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 4d1cb257..06f83166 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -700,6 +700,8 @@ void RclMain::fileExit() if (asearchform) delete asearchform; + rwSettings(true); + // Let the exit handler clean up the rest (internal recoll stuff). exit(0); }