libsaria: Don't immediately enable preference saving

We shouldn't need to save preferences during startup because at this
point only the initial values have been set.  If nothing is changed,
then nothing needs to be saved and we can save some time.  This should
also prevent any problems caused by crashing during a save.
This commit is contained in:
Bryan Schumaker 2011-01-21 22:10:37 -05:00
parent e812fbaee0
commit 802513c726
2 changed files with 8 additions and 2 deletions

View File

@ -58,6 +58,7 @@ def startup():
audio.init()
controls.init2()
plugin.load_all()
prefs.enable_save()
event.start("POSTSTART")

View File

@ -224,20 +224,25 @@ class PrefTree(Tree):
return val[0]
save_prefs_enabled = False
class PersPrefTree(PrefTree):
def __init__(self, file = None):
PrefTree.__init__(self)
self.file = file
def enable_save(self):
global save_prefs_enabled
save_prefs_enabled = True
def init_pref(self, pref, value):
val = PrefTree.init_pref(self, pref, value)
if self.file != None:
if self.file != None and save_prefs_enabled == True:
files.save(self, self.file, ".tree")
return val
def set_pref(self, pref, value):
PrefTree.set_pref(self, pref, value)
if self.file != None:
if self.file != None and save_prefs_enabled == True:
files.save(self, self.file, ".tree")
def get_pref_tree(file):