Fixes issue 18227: Closing a tab doesn't release all objects
authorMartin Taal <martin.taal@openbravo.com>
Fri, 02 Sep 2011 10:02:14 +0200
changeset 13651 367eaab45edd
parent 13650 aec4c4f24da5
child 13652 14ab9bf2c14e
Fixes issue 18227: Closing a tab doesn't release all objects
Added method to Layout to make it possible to destroy and remove members, use this method from all applicable locations
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-statusbar.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-attachments.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-help-about-widget.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quick-launch.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-community-branding-widget.js
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-showparameter-widget.js
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-statusbar.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-statusbar.js	Fri Sep 02 10:02:14 2011 +0200
@@ -288,13 +288,13 @@
 
   addIcon : function(icon) {
       // remove any existing icon or spacer
-    this.leftStatusBar.removeMember(this.leftStatusBar.members[0]);
+    this.leftStatusBar.destroyAndRemoveMembers(this.leftStatusBar.members[0]);
     this.leftStatusBar.addMember(icon, 0);
   },
 
   removeIcon : function() {
     // remove any existing icon or spacer
-    this.leftStatusBar.removeMember(this.leftStatusBar.members[0]);
+    this.leftStatusBar.destroyAndRemoveMembers(this.leftStatusBar.members[0]);
     this.leftStatusBar.addMember(this.spacer, 0);
   },
 
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-attachments.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-attachments.js	Fri Sep 02 10:02:14 2011 +0200
@@ -220,7 +220,7 @@
   
   fillAttachments: function(attachments){
     this.savedAttachments = attachments;
-    this.removeMembers(this.getMembers());
+    this.destroyAndRemoveMembers(this.getMembers());
     var hLayout = isc.HLayout.create();
     if(this.getForm().isNew){
       return;	
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-help-about-widget.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-help-about-widget.js	Fri Sep 02 10:02:14 2011 +0200
@@ -69,6 +69,10 @@
       tabPane = selectedTab.pane;
     }
     // determine if a help link should be shown or not
+    // destroy the current members
+    if (this.members[0].getMembers()) {
+      this.members[0].destroyAndRemoveMembers(this.members[0].getMembers().duplicate());
+    } 
     if (!tabPane) {
       this.members[0].setMembers([aboutLink]);
     } else {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quick-launch.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quick-launch.js	Fri Sep 02 10:02:14 2011 +0200
@@ -88,6 +88,9 @@
           index++;
         }
       }
+      if (this.members[0].getMembers()) {
+        this.members[0].destroyAndRemoveMembers(this.members[0].getMembers().duplicate());
+      } 
 
       this.members[0].setMembers(newFields);
 
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form.js	Fri Sep 02 10:02:14 2011 +0200
@@ -690,7 +690,7 @@
     this.isSaved = false;
     this.isNew = !this.personalizationData.personalizationId;
     
-    this.removeMember(this.mainLayout);
+    this.destroyAndRemoveMembers(this.mainLayout);
     this.mainLayout = null;
     this.createAddMainLayout();
 
@@ -874,7 +874,7 @@
     var i, prop, fld;
     
     if (this.fieldsTreeGrid) {
-      this.fieldsLayout.removeMember(this.fieldsTreeGrid);
+      this.fieldsLayout.destroyAndRemoveMembers(this.fieldsTreeGrid);
     }
     
     // the tree will add properties to the objects as fieldData
@@ -980,7 +980,7 @@
       }
       window = this.form.view.standardWindow;
     }
-    window.removeMember(this);
+    window.destroyAndRemoveMembers(this);
     
     // restores the tabtitle
     window.view.updateTabTitle();
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/toolbar/ob-toolbar.js	Fri Sep 02 10:02:14 2011 +0200
@@ -652,7 +652,7 @@
     for (i = 0; i < oldMembersSorted.length; i++) { /* Update the 'leftMembers' array */
       this.leftMembers.splice(oldMembersSorted[i], 1);
     }
-    this.removeMembers(oldArray); /* Remove visually the desired elements */
+    this.destroyAndRemoveMembers(oldArray); /* Remove visually the desired elements */
   },
   
   // ** {{{ removeAllLeftMembers() }}} **
@@ -864,7 +864,7 @@
     for (i = 0; i < oldMembersSorted.length; i++) { /* Update the 'rightMembers' array */
       this.rightMembers.splice(oldMembersSorted[i], 1);
     }
-    this.removeMembers(oldArray); /* Remove visually the desired elements */
+    this.destroyAndRemoveMembers(oldArray); /* Remove visually the desired elements */
   },
   
   // ** {{{ removeAllRightMembers() }}} **
--- a/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-community-branding-widget.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-community-branding-widget.js	Fri Sep 02 10:02:14 2011 +0200
@@ -130,7 +130,7 @@
     purposeStack.addMembers(toolTip);
     purposeStack.addMembers(layout.separator);
 
-    layout.removeMember(loadingBar);
+    layout.destroyAndRemoveMembers(loadingBar);
 
     layout.addMember(purposeStack);
     layout.addMember(this.versionLabel);
--- a/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js	Fri Sep 02 10:02:14 2011 +0200
@@ -359,7 +359,7 @@
       recentIndex = 0, recent, lbl, newIcon, entryLayout, icon;
     
     // start with a fresh content
-    layout.removeMembers(layout.members);
+    layout.destroyAndRemoveMembers(layout.members);
     
     // reads the list of recents and displays them
     recentList = OB.Layout.ViewManager.recentManager.getRecentValue('OBUIAPP_RecentViewList');
@@ -453,7 +453,7 @@
       lbl, newIcon, entryLayout, icon;
     
     // start with a fresh content
-    layout.removeMembers(layout.members);
+    layout.destroyAndRemoveMembers(layout.members);
 
     // reads the list of recents and displays them
     recentList = OB.Layout.ViewManager.recentManager.getRecentValue('OBUIAPP_RecentDocumentsList');
--- a/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-showparameter-widget.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-showparameter-widget.js	Fri Sep 02 10:02:14 2011 +0200
@@ -25,7 +25,7 @@
   setParameters: function(parameters){
     this.Super('setParameters', arguments);
     var oldForm = this.displayForm;
-    this.windowContents.removeMember(this.displayForm);
+    this.windowContents.destroyAndRemoveMembers(this.displayForm);
     this.windowContents.addMember(this.createDisplayForm());
     oldForm.destroy();
   },
--- a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Thu Sep 01 16:47:28 2011 +0200
+++ b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Fri Sep 02 10:02:14 2011 +0200
@@ -50,6 +50,20 @@
 
 isc.StaticTextItem.getPrototype().getCanFocus = function() {return false;};
 
+isc.Layout.addProperties({
+  
+  destroyAndRemoveMembers: function(toDestroy) {
+    var i;
+    if (!isc.isA.Array(toDestroy)) {
+      toDestroy = [toDestroy];
+    }
+    for (i = 0; i < toDestroy.length; i++) {
+      toDestroy[i].destroy();
+    }
+    this.removeMembers(toDestroy);
+  }
+});
+
 isc.TextItem.addProperties({
   // see comments in super type for useDisabledEventMask
   // http://forums.smartclient.com/showthread.php?p=70160#post70160