Bug 714841 - With 30 lightweight themes installed, Add-ons Manager appearance pane is slow to load. r=dtownsend

This commit is contained in:
Blair McBride 2012-02-15 15:07:30 +13:00
parent b739574682
commit 31fb50a746

View File

@ -92,6 +92,8 @@ __defineSetter__("_maxUsedThemes", function(aVal) {
return this._maxUsedThemes = aVal;
});
var _usedThemes = null;
// Holds the ID of the theme being enabled or disabled while sending out the
// events so cached AddonWrapper instances can return correct values for
// permissions and pendingOperations
@ -100,12 +102,16 @@ var _themeIDBeingDisbled = null;
var LightweightThemeManager = {
get usedThemes () {
if (_usedThemes)
return _usedThemes;
try {
return JSON.parse(_prefs.getComplexValue("usedThemes",
Ci.nsISupportsString).data);
_usedThemes = JSON.parse(_prefs.getComplexValue("usedThemes",
Ci.nsISupportsString).data);
} catch (e) {
return [];
_usedThemes = [];
}
return _usedThemes;
},
get currentTheme () {
@ -408,7 +414,8 @@ var LightweightThemeManager = {
return;
}
aCallback([new AddonWrapper(a) for each (a in this.usedThemes)]);
let themes = this.usedThemes;
aCallback([new AddonWrapper(a) for each (a in themes)]);
},
};
@ -746,6 +753,10 @@ function _prefObserver(aSubject, aTopic, aData) {
// Update the theme list to remove any themes over the number we keep
_updateUsedThemes(LightweightThemeManager.usedThemes);
break;
case "usedThemes":
// Clear the cache - it will be repopulated next time it's used.
_usedThemes = null;
break;
}
}