Fix leak by calling removeObserver for observer implemented in JS so it doesn't stay around until the pref service shuts down. b=231384 r=daniel@glazman.org sr=bryner@brianryner.com

This commit is contained in:
dbaron%dbaron.org 2004-01-21 21:15:44 +00:00
Родитель 989a0a4d36
Коммит bd396f295c
2 изменённых файлов: 40 добавлений и 12 удалений

Просмотреть файл

@ -168,18 +168,31 @@ const gEditorToolbarPrefListener =
function nsButtonPrefListener()
{
try {
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.addObserver(this.domain, this, false);
} catch(ex) {
dump("Failed to observe prefs: " + ex + "\n");
}
this.startup();
}
// implements nsIObserver
nsButtonPrefListener.prototype =
{
domain: "editor.use_css",
startup: function()
{
try {
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.addObserver(this.domain, this, false);
} catch(ex) {
dump("Failed to observe prefs: " + ex + "\n");
}
},
shutdown: function()
{
try {
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.removeObserver(this.domain, this);
} catch(ex) {
dump("Failed to remove pref observers: " + ex + "\n");
}
},
observe: function(subject, topic, prefName)
{
if (!IsHTMLEditor())
@ -691,6 +704,7 @@ function EditorResetFontAndColorAttributes()
function EditorShutdown()
{
RemoveToolbarPrefListener();
gCSSPrefListener.shutdown();
try {
var commandManager = GetCurrentCommandManager();

Просмотреть файл

@ -163,18 +163,31 @@ const gEditorToolbarPrefListener =
function nsButtonPrefListener()
{
try {
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.addObserver(this.domain, this, false);
} catch(ex) {
dump("Failed to observe prefs: " + ex + "\n");
}
this.startup();
}
// implements nsIObserver
nsButtonPrefListener.prototype =
{
domain: "editor.use_css",
startup: function()
{
try {
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.addObserver(this.domain, this, false);
} catch(ex) {
dump("Failed to observe prefs: " + ex + "\n");
}
},
shutdown: function()
{
try {
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.removeObserver(this.domain, this);
} catch(ex) {
dump("Failed to remove pref observers: " + ex + "\n");
}
},
observe: function(subject, topic, prefName)
{
if (!IsHTMLEditor())
@ -684,6 +697,7 @@ function EditorResetFontAndColorAttributes()
function EditorShutdown()
{
RemoveToolbarPrefListener();
gCSSPrefListener.shutdown();
try {
var commandManager = GetCurrentCommandManager();