Fix leaks by removing preference observers. b=386665 r=tony@ponderer.org

This commit is contained in:
dbaron@dbaron.org 2007-07-09 13:53:01 -07:00
parent 1446a2ddd6
commit f9254c5f95
2 changed files with 12 additions and 0 deletions

View File

@ -174,6 +174,7 @@ PROT_PhishingWarden.prototype.QueryInterface = function(iid) {
* Cleanup on shutdown.
*/
PROT_PhishingWarden.prototype.shutdown = function() {
this.prefs_.removeAllObservers();
this.progressListener_.callback = null;
this.progressListener_ = null;
this.listManager_ = null;

View File

@ -209,6 +209,17 @@ G_Preferences.prototype.removeObserver = function(which, callback) {
this.prefs_.removeObserver(which, observer);
}
/**
* Remove all preference observers registered through this object.
*/
G_Preferences.prototype.removeAllObservers = function() {
for (var which in this.observers_) {
for each (var observer in this.observers_[which].observers) {
this.prefs_.removeObserver(which, observer);
}
}
this.observers_ = {};
}
/**
* Helper class that knows how to observe preference changes and