Bug 960864 - Implement the _initialized flag instead of _addedObserver and the half-broken _destroyed. r=gavin

--HG--
extra : rebase_source : 396b859dc30dc91bce27c6b576a1814f5d65d7e5
This commit is contained in:
Dão Gottwald 2014-01-24 00:44:12 +01:00
parent 7bfa2e0923
commit 1f898c5c0f

View File

@ -84,11 +84,11 @@
.getService(Components.interfaces.nsIObserverService);
os.addObserver(this, "browser-search-engine-modified", false);
this._addedObserver = true;
this._initialized = true;
this.searchService.init((function search_init_cb(aStatus) {
// Bail out if the binding's been destroyed
if (this._destroyed)
if (!this._initialized)
return;
if (Components.isSuccessCode(aStatus)) {
@ -101,13 +101,12 @@
]]></constructor>
<destructor><![CDATA[
this._destroyed = true;
if (this._initialized) {
this._initialized = false;
if (this._addedObserver) {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.removeObserver(this, "browser-search-engine-modified");
this._addedObserver = false;
}
// Make sure to break the cycle from _textbox to us. Otherwise we leak