Bug 947771 - properly unregister DBViewWrapper from folder listeners after closing Search messages window. r=mkmelin
authoraceman <acelists@atlas.sk>
Sun, 02 Dec 2018 13:56:00 +0100
changeset 33840 440dbc342936fc1a2eea7b63d76c6e9ae95a5cf7
parent 33839 140498abac70cc52fb1d91d73d100eadbff14795
child 33841 78ed6c7be87defefdbce82e1bd1e8dc7b59e9ef3
push id388
push userclokep@gmail.com
push dateMon, 28 Jan 2019 20:54:56 +0000
reviewersmkmelin
bugs947771
Bug 947771 - properly unregister DBViewWrapper from folder listeners after closing Search messages window. r=mkmelin
mail/base/content/SearchDialog.js
mail/base/content/SearchDialog.xul
mail/base/content/messageDisplay.js
mail/base/modules/DBViewWrapper.jsm
--- a/mail/base/content/SearchDialog.js
+++ b/mail/base/content/SearchDialog.js
@@ -5,31 +5,32 @@
 /* import-globals-from ../../../../toolkit/content/globalOverlay.js */
 /* import-globals-from ../../../mailnews/base/search/content/searchTermOverlay.js */
 /* import-globals-from folderDisplay.js */
 /* import-globals-from mailWindow.js */
 /* import-globals-from mailWindowOverlay.js */
 /* import-globals-from messageDisplay.js */
 /* import-globals-from threadPane.js */
 
+"use strict";
+
 ChromeUtils.import("resource:///modules/MailUtils.jsm");
 ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 var gCurrentFolder;
 
 var gFolderDisplay;
 // Although we don't display messages, we have a message display object to
 //  simplify our code.  It's just always disabled.
 var gMessageDisplay;
 
 var gFolderPicker;
 var gStatusFeedback;
 var gTimelineEnabled = false;
-var RDF;
 var gSearchBundle;
 
 // Datasource search listener -- made global as it has to be registered
 // and unregistered in different functions.
 var gDataSourceSearchListener;
 var gViewSearchListener;
 
 var gSearchStopButton;
@@ -222,17 +223,17 @@ function searchOnLoad() {
   initializeSearchWindowWidgets();
   messenger = Cc["@mozilla.org/messenger;1"]
                 .createInstance(Ci.nsIMessenger);
 
   gSearchBundle = document.getElementById("bundle_search");
   gSearchStopButton.setAttribute("label", gSearchBundle.getString("labelForSearchButton"));
   gSearchStopButton.setAttribute("accesskey", gSearchBundle.getString("labelForSearchButton.accesskey"));
 
-  gMessageDisplay = new NeverVisisbleMessageDisplayWidget();
+  gMessageDisplay = new NeverVisibleMessageDisplayWidget();
   gFolderDisplay = new SearchFolderDisplayWidget(gMessageDisplay);
   gFolderDisplay.messenger = messenger;
   gFolderDisplay.msgWindow = msgWindow;
   gFolderDisplay.tree = document.getElementById("threadTree");
   gFolderDisplay.treeBox = gFolderDisplay.tree.boxObject;
   gFolderDisplay.view.openSearchView();
   gFolderDisplay.makeActive();
 
--- a/mail/base/content/SearchDialog.xul
+++ b/mail/base/content/SearchDialog.xul
@@ -4,17 +4,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 <?xml-stylesheet href="chrome://messenger/content/bindings.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/searchDialog.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderPane.css" type="text/css"?>
 <?xml-stylesheet href="chrome://messenger/skin/folderMenus.css" type="text/css"?>
 
-<!DOCTYPE dialog [
+<!DOCTYPE window [
   <!ENTITY % SearchDialogDTD SYSTEM "chrome://messenger/locale/SearchDialog.dtd">
   %SearchDialogDTD;
   <!ENTITY % searchTermDTD SYSTEM "chrome://messenger/locale/searchTermOverlay.dtd">
   %searchTermDTD;
 ]>
 
 <window id="searchMailWindow"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
--- a/mail/base/content/messageDisplay.js
+++ b/mail/base/content/messageDisplay.js
@@ -549,20 +549,20 @@ MessageTabDisplayWidget.prototype = {
   },
 };
 
 /**
  * The search dialog has no message preview pane, and so wants a message
  *  display widget that is never visible.  No one other than the search
  *  dialog should use this because the search dialog is bad UI.
  */
-function NeverVisisbleMessageDisplayWidget() {
+function NeverVisibleMessageDisplayWidget() {
   MessageDisplayWidget.call(this);
 }
-NeverVisisbleMessageDisplayWidget.prototype = {
+NeverVisibleMessageDisplayWidget.prototype = {
   __proto__: MessageDisplayWidget.prototype,
   get visible() {
     return false;
   },
   onSelectedMessagesChanged() {
     return false;
   },
   _updateActiveMessagePane() {
--- a/mail/base/modules/DBViewWrapper.jsm
+++ b/mail/base/modules/DBViewWrapper.jsm
@@ -540,16 +540,24 @@ DBViewWrapper.prototype = {
    * @return true if the folder being displayed is not a real folder at all,
    *     but rather the result of an un-scoped search, such as a gloda search.
    */
   get isSynthetic() {
     return this._underlyingData == this.kUnderlyingSynthetic;
   },
 
   /**
+   * @return true if the folder being displayed is not a real folder at all,
+   *         but rather the result of a search.
+   */
+  get isSearch() {
+    return this._underlyingData == this.kUnderlyingSearchView;
+  },
+
+  /**
    * Check if the folder in question backs the currently displayed folder.  For
    *  a virtual folder, this is a test of whether the virtual folder includes
    *  messages from the given folder.  For a 'real' single folder, this is
    *  effectively a test against displayedFolder.
    * If you want to see if the displayed folder is a folder, just compare
    *  against the displayedFolder attribute.
    */
   isUnderlyingFolder(aFolder) {
@@ -673,16 +681,21 @@ DBViewWrapper.prototype = {
       }
 
       this.folderLoading = false;
       this.displayedFolder = null;
     }
 
     FolderNotificationHelper.removeNotifications(this._underlyingFolders,
                                                  this);
+    if (this.isSearch || this.isSynthetic) {
+      // Opposite of FolderNotificationHelper.noteCuriosity(this)
+      FolderNotificationHelper.removeNotifications(null, this);
+    }
+
     if (this._underlyingFolders) {
       // (potentially) zero out the underlying msgDatabase references
       for (let folder of this._underlyingFolders)
         this._releaseFolderDatabase(folder);
     }
 
     // kill off the view and its search association
     if (this.dbView) {