mirror of
https://github.com/fergalmoran/picard.git
synced 2026-03-21 04:35:13 +00:00
PICARD-2088: Override QSettings config file syncing
As the default implementation for synchronizing the config file can lead to application freezes override it. Ensure the config file is not updated by more than one process by locking the file using fasteners.
This commit is contained in:
@@ -32,6 +32,8 @@ import os
|
||||
import shutil
|
||||
import threading
|
||||
|
||||
import fasteners
|
||||
|
||||
from PyQt5 import QtCore
|
||||
|
||||
from picard import (
|
||||
@@ -129,6 +131,7 @@ class Config(QtCore.QSettings):
|
||||
"""Common initializer method for :meth:`from_app` and
|
||||
:meth:`from_file`."""
|
||||
|
||||
self.setAtomicSyncRequired(False)
|
||||
self.application = ConfigSection(self, "application")
|
||||
self.setting = ConfigSection(self, "setting")
|
||||
self.persist = ConfigSection(self, "persist")
|
||||
@@ -139,6 +142,18 @@ class Config(QtCore.QSettings):
|
||||
self._version = Version.from_string(self.application["version"])
|
||||
self._upgrade_hooks = dict()
|
||||
|
||||
def event(self, event):
|
||||
if event.type() == QtCore.QEvent.UpdateRequest:
|
||||
log.debug('Config file update requested on thread %r', threading.get_ident())
|
||||
self.sync()
|
||||
return True
|
||||
else:
|
||||
return super().event(event)
|
||||
|
||||
def sync(self):
|
||||
with fasteners.InterProcessLock(self.fileName()):
|
||||
super().sync()
|
||||
|
||||
@classmethod
|
||||
def from_app(cls, parent):
|
||||
"""Build a Config object using the default configuration file
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
python-dateutil==2.8.1
|
||||
discid==1.2.0
|
||||
fasteners==0.16
|
||||
markdown==3.2.2
|
||||
mutagen==1.45.1
|
||||
pyobjc-core==6.2.2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
python-dateutil==2.8.1
|
||||
discid==1.2.0
|
||||
fasteners==0.16
|
||||
markdown==3.2.2
|
||||
mutagen==1.45.1
|
||||
pyobjc-core==6.2.2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
python-dateutil==2.8.1
|
||||
discid==1.2.0
|
||||
fasteners==0.16
|
||||
markdown==3.2.2
|
||||
mutagen==1.45.1
|
||||
PyQt5==5.15.2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
python-dateutil>=2.7.3
|
||||
discid
|
||||
fasteners
|
||||
markdown
|
||||
mutagen>=1.37
|
||||
pyobjc-core<7.0; sys_platform == 'darwin'
|
||||
|
||||
Reference in New Issue
Block a user