commit/StationPlaylist: josephsl: Config cache (7.0-dev): New profiles are now saved to disk.

  • From: commits-noreply@xxxxxxxxxxxxx
  • To: nvda-addons-commits@xxxxxxxxxxxxx
  • Date: Thu, 14 Jan 2016 05:33:57 -0000

1 new commit in StationPlaylist:

https://bitbucket.org/nvdaaddonteam/stationplaylist/commits/9d9da0611ece/
Changeset:   9d9da0611ece
Branch:      master
User:        josephsl
Date:        2016-01-14 05:33:47+00:00
Summary:     Config cache (7.0-dev): New profiles are now saved to disk.

Oops, a downside to caching found: if a new profile is created (brand new or as 
a copy), this fact isn't recorded. The cache will see the 'new' profile as an 
existing one, therefore it'll not save the newly created profile to disk.
Also, when copying profiles, profile-specific keys are copied insead of all 
keys being copied over.

Affected #:  1 file

diff --git a/addon/appModules/splstudio/splconfig.py 
b/addon/appModules/splstudio/splconfig.py
index 92aa606..65635dd 100755
--- a/addon/appModules/splstudio/splconfig.py
+++ b/addon/appModules/splstudio/splconfig.py
@@ -552,6 +552,8 @@ def _preSave(conf):
 # For the most part, no setting will be modified.
 def shouldSave(profile):
        tree = None if profile.filename == SPLIni else profile.name
+       # One downside of caching: new profiles are not recognized as such.
+       if "___new___" in _SPLCache[tree]: return True
        for section in profile.keys():
                if isinstance(profile[section], dict):
                        for key in profile[section]:
@@ -1433,7 +1435,7 @@ class NewProfileDialog(wx.Dialog):
                self.Center(wx.BOTH | wx.CENTER_ON_SCREEN)
 
        def onOk(self, evt):
-               global SPLConfigPool
+               global SPLConfigPool, _SPLCache
                profileNames = [profile.name for profile in SPLConfigPool]
                name = api.filterFileName(self.profileName.Value)
                if not name:
@@ -1448,12 +1450,14 @@ class NewProfileDialog(wx.Dialog):
                        os.mkdir(SPLProfiles)
                newProfilePath = os.path.join(SPLProfiles, namePath)
                SPLConfigPool.append(unlockConfig(newProfilePath, 
profileName=name))
+               # Make the cache know this is a new profile.
+               # If nothing happens to this profile, the newly created profile 
will be saved to disk.
+               _SPLCache[name]["___new___"] = True
                if self.copy:
                        newProfile = SPLConfigPool[-1]
                        baseProfile = 
getProfileByName(self.baseProfiles.GetStringSelection())
-                       for setting in baseProfile:
+                       for setting in newProfile.keys():
                                try:
-                                       # Go through all settings (including 
profile-specific ones for now).
                                        # 6.1/7.0: Only iterate through 
mutatable keys.
                                        if baseProfile[setting] != 
newProfile[setting]:
                                                newProfile[setting] = 
baseProfile[setting]

Repository URL: https://bitbucket.org/nvdaaddonteam/stationplaylist/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.

Other related posts:

  • » commit/StationPlaylist: josephsl: Config cache (7.0-dev): New profiles are now saved to disk. - commits-noreply