Bug 1225165 - Clean up properly when closing the subscriptions window using the Close button. r=mkmelin, a=rkent
authoralta88
Sat, 28 Nov 2015 12:36:29 -0700
changeset 26472 40d81c6e93bbbe41f3a3af0e6a767978a993f30b
parent 26471 db4f54bf946b30c78535a39f25f7de6ea8fad204
child 26473 3c5164cb201316b1f36f0276cdccc5e92cd7e26a
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, rkent
bugs1225165
Bug 1225165 - Clean up properly when closing the subscriptions window using the Close button. r=mkmelin, a=rkent
mailnews/extensions/newsblog/content/feed-subscriptions.js
mailnews/extensions/newsblog/content/feed-subscriptions.xul
--- a/mailnews/extensions/newsblog/content/feed-subscriptions.js
+++ b/mailnews/extensions/newsblog/content/feed-subscriptions.js
@@ -1827,23 +1827,19 @@ var FeedSubscriptions = {
       }
     }
     aEvent.stopPropagation();
   },
 
   // Listener for folder pane changes.
   FolderListener: {
     get feedWindow() {
-      if (this._feedWindow)
-        return this._feedWindow;
       let subscriptionsWindow =
         Services.wm.getMostRecentWindow("Mail:News-BlogSubscriptions");
-      if (subscriptionsWindow)
-        return this._feedWindow = subscriptionsWindow.FeedSubscriptions;
-      return null;
+      return subscriptionsWindow ? subscriptionsWindow.FeedSubscriptions : null;
     },
 
     get currentSelectedIndex() {
       return this.feedWindow ? this.feedWindow.mView.selection.currentIndex : -1;
     },
 
     get currentSelectedItem() {
       return this.feedWindow ? this.feedWindow.mView.currentItem : null;
@@ -1853,21 +1849,21 @@ var FeedSubscriptions = {
     {
       if (aFolder.server.type != "rss" ||
           FeedUtils.isInTrash(aFolder))
         return;
 
       let parentFolder = aFolder.isServer ? aFolder : aFolder.parent;
       FeedUtils.log.debug("folderAdded: folder:parent - " + aFolder.name + ":" +
                           (parentFolder ? parentFolder.filePath.path : "(null)"));
-      let feedWindow = this.feedWindow;
 
-      if (!parentFolder)
+      if (!parentFolder || !this.feedWindow))
         return;
 
+      let feedWindow = this.feedWindow;
       let curSelIndex = this.currentSelectedIndex;
       let curSelItem = this.currentSelectedItem;
       let firstVisRow = feedWindow.mView.treeBox.getFirstVisibleRow();
       let indexInView = feedWindow.mView.getItemInViewIndex(parentFolder);
       let open = indexInView != null;
 
       if (aFolder.isServer)
       {
@@ -1914,16 +1910,19 @@ var FeedSubscriptions = {
     },
 
     folderDeleted: function(aFolder)
     {
       if (aFolder.server.type != "rss" || FeedUtils.isInTrash(aFolder))
         return;
 
       FeedUtils.log.debug("folderDeleted: folder - " + aFolder.name);
+      if (!this.feedWindow)
+        return;
+
       let feedWindow = this.feedWindow;
       let curSelIndex = this.currentSelectedIndex;
       let indexInView = feedWindow.mView.getItemInViewIndex(aFolder);
       let open = indexInView != null;
 
       // Delete the folder from the tree row cache.
       feedWindow.selectFolder(aFolder, { select: false, open: false, remove: true });
 
@@ -1939,16 +1938,19 @@ var FeedSubscriptions = {
 
     folderRenamed: function(aOrigFolder, aNewFolder)
     {
       if (aNewFolder.server.type != "rss" || FeedUtils.isInTrash(aNewFolder))
         return;
 
       FeedUtils.log.debug("folderRenamed: old:new - " +
                           aOrigFolder.name + ":" + aNewFolder.name);
+      if (!this.feedWindow)
+        return;
+
       let feedWindow = this.feedWindow;
       let curSelIndex = this.currentSelectedIndex;
       let curSelItem = this.currentSelectedItem;
       let firstVisRow = feedWindow.mView.treeBox.getFirstVisibleRow();
       let indexInView = feedWindow.mView.getItemInViewIndex(aOrigFolder);
       let open = indexInView != null;
 
       // Rebuild the renamed folder's item in the tree row cache.
@@ -1986,16 +1988,19 @@ var FeedSubscriptions = {
 
     folderMoveCopyCompleted: function(aMove, aSrcFolder, aDestFolder)
     {
       if (aDestFolder.server.type != "rss")
         return;
 
       FeedUtils.log.debug("folderMoveCopyCompleted: move:src:dest - " +
                           aMove + ":" + aSrcFolder.name + ":" + aDestFolder.name);
+      if (!this.feedWindow)
+        return;
+
       let feedWindow = this.feedWindow;
       let curSelIndex = this.currentSelectedIndex;
       let curSelItem = this.currentSelectedItem;
       let firstVisRow = feedWindow.mView.treeBox.getFirstVisibleRow();
       let indexInView = feedWindow.mView.getItemInViewIndex(aSrcFolder);
       let destIndexInView = feedWindow.mView.getItemInViewIndex(aDestFolder);
       let open = indexInView != null || destIndexInView != null;
       let parentIndex = feedWindow.mView.getItemInViewIndex(aDestFolder.parent ||
--- a/mailnews/extensions/newsblog/content/feed-subscriptions.xul
+++ b/mailnews/extensions/newsblog/content/feed-subscriptions.xul
@@ -212,13 +212,13 @@
                 tooltiptext="&button.exportOPML.tooltip;"
                 oncommand="FeedSubscriptions.exportOPML(event);"/>
 
         <spacer flex="1"/>
 
         <button id="close"
                 label="&button.close.label;"
                 icon="close"
-                oncommand="window.close();"/>
+                oncommand="if (FeedSubscriptions.onClose()) window.close();"/>
       </hbox>
     </hbox>
   </vbox>
 </window>