Related to issue 18227: Closing a tab doesn't release all objects
authorMartin Taal <martin.taal@openbravo.com>
Fri, 02 Sep 2011 11:19:10 +0200
changeset 13652 14ab9bf2c14e
parent 13651 367eaab45edd
child 13653 536749f809ab
Related to issue 18227: Closing a tab doesn't release all objects
Solved memory leak in window personalization and with record components
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalization-treegrid.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Fri Sep 02 10:02:14 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-grid.js	Fri Sep 02 11:19:10 2011 +0200
@@ -331,6 +331,19 @@
     this.Super('initWidget', arguments);
   },
   
+  //  http://forums.smartclient.com/showthread.php?p=72177#post72177
+  destroy: function() {
+    var i, components;
+    this.Super('destroy', arguments);
+    
+    components = this.getRecordComponentPool();
+    if (components) {
+      for (i = 0; i < components.length; i++) {
+        components[i].destroy();
+      }
+    }
+  },
+  
   clearFilter: function(keepFilterClause, noPerformAction){
     var i = 0, fld;
     if (!keepFilterClause) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalization-treegrid.js	Fri Sep 02 10:02:14 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalization-treegrid.js	Fri Sep 02 11:19:10 2011 +0200
@@ -110,6 +110,13 @@
    this.Super('initWidget', arguments);
   },
   
+  destroy: function() {
+    if (this.data) {
+      this.data.destroy();
+    }
+    this.Super('destroy', arguments);
+  },
+  
   // open/close a folder on folder click
   folderClick: function (viewer, folder, recordNum) {
     if (this.data.isOpen(folder)) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form.js	Fri Sep 02 10:02:14 2011 +0200
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/personalization/ob-personalize-form.js	Fri Sep 02 11:19:10 2011 +0200
@@ -873,8 +873,9 @@
   buildFieldsTreeGrid: function() {
     var i, prop, fld;
     
+    this.fieldsLayout.destroyAndRemoveMembers(this.fieldsLayout.getMembers());
     if (this.fieldsTreeGrid) {
-      this.fieldsLayout.destroyAndRemoveMembers(this.fieldsTreeGrid);
+      this.fieldsTreeGrid.destroy();
     }
     
     // the tree will add properties to the objects as fieldData