Used to write settings in the exit handler, do it earlier because it crashes qt5

This commit is contained in:
Jean-Francois Dockes 2015-04-05 09:08:55 +02:00
parent 1b786815b7
commit f2ce709a15
3 changed files with 11 additions and 10 deletions

View file

@ -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<string>::iterator it = tl.begin(); it != tl.end(); it++)
prefs.asearchSubdirHist.push_front(QString::fromUtf8(it->c_str()));
}
if (!writing)
havereadsettings = true;
}
string PrefsPack::stemlang()

View file

@ -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<TempFile> o_tempfiles;
/* Keep an array of temporary files for deletion at exit. It happens that we
@ -155,10 +150,6 @@ bool getStemLangs(vector<string>& 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()) {

View file

@ -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);
}