mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
qt: save prefs on close more predictably
Ticket #379 reports crashes on quit due to `willSavePrefs` being called when result and details dialogs are already freed. I can't reproduce the crash, but it's still a bad idea to rely on the timing of `aboutToQuit()` to launch this process. This commits uses a more predictable place to emit `willSavePrefs` and I'm pretty sure it will fix the crash at #379.
This commit is contained in:
14
qt/app.py
14
qt/app.py
@@ -7,7 +7,7 @@
|
||||
import sys
|
||||
import os.path as op
|
||||
|
||||
from PyQt5.QtCore import QTimer, QObject, QCoreApplication, QUrl, pyqtSignal
|
||||
from PyQt5.QtCore import QTimer, QObject, QUrl, pyqtSignal
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtWidgets import QApplication, QFileDialog, QDialog, QMessageBox
|
||||
|
||||
@@ -73,7 +73,6 @@ class DupeGuru(QObject):
|
||||
# In some circumstances, the nag is hidden by other window, which may make the user think
|
||||
# that the application haven't launched.
|
||||
QTimer.singleShot(0, self.finishedLaunching)
|
||||
QCoreApplication.instance().aboutToQuit.connect(self.application_will_terminate)
|
||||
|
||||
def _setupActions(self):
|
||||
# Setup actions that are common to both the directory dialog and the results window.
|
||||
@@ -158,6 +157,12 @@ class DupeGuru(QObject):
|
||||
if self.resultWindow is not None:
|
||||
self.resultWindow.show()
|
||||
|
||||
def shutdown(self):
|
||||
self.willSavePrefs.emit()
|
||||
self.prefs.save()
|
||||
self.model.save()
|
||||
QApplication.quit()
|
||||
|
||||
#--- Signals
|
||||
willSavePrefs = pyqtSignal()
|
||||
|
||||
@@ -170,11 +175,6 @@ class DupeGuru(QObject):
|
||||
"you set your system locale properly."
|
||||
QMessageBox.warning(self.directories_dialog, "Wrong Locale", msg)
|
||||
|
||||
def application_will_terminate(self):
|
||||
self.willSavePrefs.emit()
|
||||
self.prefs.save()
|
||||
self.model.save()
|
||||
|
||||
def clearPictureCacheTriggered(self):
|
||||
title = tr("Clear Picture Cache")
|
||||
msg = tr("Do you really want to remove all your cached picture analysis?")
|
||||
|
||||
Reference in New Issue
Block a user