Bug 522261: Some code is firing after the browser window closes [r=gavin.sharp]

This commit is contained in:
Mark Finkle 2009-10-14 15:04:33 -04:00
Родитель 418432af45
Коммит a620af1b51
5 изменённых файлов: 30 добавлений и 4 удалений

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

@ -239,6 +239,11 @@ BrowserView.prototype = {
this._idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(Ci.nsIIdleService); this._idleService = Cc["@mozilla.org/widget/idleservice;1"].getService(Ci.nsIIdleService);
this._idleService.addIdleObserver(this._idleServiceObserver, kBrowserViewPrefetchBeginIdleWait); this._idleService.addIdleObserver(this._idleServiceObserver, kBrowserViewPrefetchBeginIdleWait);
}, },
uninit: function uninit() {
this.setBrowser(null, null, false);
this._idleService.removeIdleObserver(this._idleServiceObserver, kBrowserViewPrefetchBeginIdleWait);
},
getVisibleRect: function getVisibleRect() { getVisibleRect: function getVisibleRect() {
return this._visibleRectFactory(); return this._visibleRectFactory();

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

@ -409,10 +409,12 @@ var BrowserUI = {
ExtensionsView.init(); ExtensionsView.init();
DownloadsView.init(); DownloadsView.init();
PreferencesView.init(); PreferencesView.init();
ConsoleView.init();
}, },
uninit : function() { uninit : function() {
ExtensionsView.uninit(); ExtensionsView.uninit();
ConsoleView.uninit();
}, },
update : function(aState) { update : function(aState) {

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

@ -570,8 +570,7 @@ var Browser = {
}, },
shutdown: function() { shutdown: function() {
this._browserView.setBrowser(null, null, false); this._browserView.uninit();
BrowserUI.uninit(); BrowserUI.uninit();
var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);

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

@ -317,7 +317,7 @@
<toolbarbutton id="tool-addons" type="radio" group="1" class="panel-button button-image" linkedpanel="addons-container"/> <toolbarbutton id="tool-addons" type="radio" group="1" class="panel-button button-image" linkedpanel="addons-container"/>
<toolbarbutton id="tool-downloads" type="radio" group="1" class="panel-button button-image" linkedpanel="downloads-container"/> <toolbarbutton id="tool-downloads" type="radio" group="1" class="panel-button button-image" linkedpanel="downloads-container"/>
<toolbarbutton id="tool-preferences" type="radio" group="1" checked="true" class="panel-button button-image" linkedpanel="prefs-container"/> <toolbarbutton id="tool-preferences" type="radio" group="1" checked="true" class="panel-button button-image" linkedpanel="prefs-container"/>
<toolbarbutton id="tool-console" type="radio" group="1" hidden="true" class="panel-button button-image" linkedpanel="console-container" oncommand="ConsoleView.init();"/> <toolbarbutton id="tool-console" type="radio" group="1" hidden="true" class="panel-button button-image" linkedpanel="console-container"/>
</box> </box>
<deck id="panel-items" selectedIndex="2" flex="1"> <deck id="panel-items" selectedIndex="2" flex="1">
<vbox id="addons-container" flex="1"> <vbox id="addons-container" flex="1">

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

@ -37,6 +37,7 @@
let ConsoleView = { let ConsoleView = {
_list: null, _list: null,
_console: null,
_evalTextbox: null, _evalTextbox: null,
_evalFrame: null, _evalFrame: null,
_evalCode: "", _evalCode: "",
@ -54,6 +55,20 @@ let ConsoleView = {
this._count = 0; this._count = 0;
this.limit = 250; this.limit = 250;
let self = this;
let panels = document.getElementById("panel-items");
panels.addEventListener("select",
function(aEvent) {
if (panels.selectedPanel.id == "console-container")
self._delayedInit();
},
false);
},
_delayedInit: function cv__delayedInit() {
if (this._console)
return;
this._console = Cc['@mozilla.org/consoleservice;1'].getService(Ci.nsIConsoleService); this._console = Cc['@mozilla.org/consoleservice;1'].getService(Ci.nsIConsoleService);
this._console.registerListener(this); this._console.registerListener(this);
@ -68,8 +83,13 @@ let ConsoleView = {
let self = this; let self = this;
this._evalFrame.addEventListener("load", function() { self.loadOrDisplayResult(); }, true); this._evalFrame.addEventListener("load", function() { self.loadOrDisplayResult(); }, true);
}, },
uninit: function cv_uninit() {
if (this._console)
this._console.unregisterListener(this);
},
observe : function(aObject) { observe: function(aObject) {
this.appendItem(aObject); this.appendItem(aObject);
}, },