Bug 903274 - Have the search bar binding's initialization callback bail out if the binding is destroyed. r=MattN, a=bajaj
authorGavin Sharp <gavin@gavinsharp.com>
Wed, 08 Jan 2014 18:34:16 -0800
changeset 175665 016a7b78157af10f8f42364d2b6706c52d952abe
parent 175664 68c89b39ed6cb920e2c0abf4ee06c72d4621578e
child 175666 63f68740f111edabbd24da311e2cebb233200c93
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, bajaj
bugs903274
milestone28.0a2
Bug 903274 - Have the search bar binding's initialization callback bail out if the binding is destroyed. r=MattN, a=bajaj
browser/components/search/content/search.xml
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -77,26 +77,32 @@
         var os =
                Components.classes["@mozilla.org/observer-service;1"]
                          .getService(Components.interfaces.nsIObserverService);
         os.addObserver(this, "browser-search-engine-modified", false);
 
         this._addedObserver = true;
 
         this.searchService.init((function search_init_cb(aStatus) {
+          // Bail out if the binding's been destroyed
+          if (this._destroyed)
+            return;
+
           if (Components.isSuccessCode(aStatus)) {
             // Refresh the display (updating icon, etc)
             this.updateDisplay();
           } else {
             Components.utils.reportError("Cannot initialize search service, bailing out: " + aStatus);
           }
         }).bind(this));
       ]]></constructor>
 
       <destructor><![CDATA[
+        this._destroyed = true;
+
         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