details:   https://code.openbravo.com/erp/devel/pi/rev/3823c5ec27a4
changeset: 13605:3823c5ec27a4
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Fri Aug 26 15:00:34 2011 +0200
summary:   Issue 18227: Move the destroy of dataSource to the form and grid
To avoid problems of setting/resetting flags (when the datasource needs to be
destroyed). This action is now in the OBFormView and OBViewGrid destroy
method.

details:   https://code.openbravo.com/erp/devel/pi/rev/cff2f670c700
changeset: 13606:cff2f670c700
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Fri Aug 26 15:02:36 2011 +0200
summary:   Issue 18227: dataSource/optionDataSource is now destroyed on 
form/grid destroy
The destroy methos of OBViewGrid and OBViewForm takes care of destroying the
datasources associated to items/fields

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-linked-items.js
 |   1 -
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
              |  27 +++++++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
              |  28 ++++++-
 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
       |  36 ----------
 4 files changed, 52 insertions(+), 40 deletions(-)

diffs (164 lines):

diff -r 90094abfaff9 -r cff2f670c700 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-linked-items.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-linked-items.js
        Fri Aug 26 09:39:52 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form-linked-items.js
        Fri Aug 26 15:02:36 2011 +0200
@@ -315,7 +315,6 @@
     hLayout.addMember(this.linkedItemListGrid);
     
     this.messageLabel = isc.Label.create({
-      ID: 'messageLabel',
       width: '100%',
       height: '100%',
       canFocus: true
diff -r 90094abfaff9 -r cff2f670c700 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Fri Aug 26 09:39:52 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/form/ob-view-form.js
     Fri Aug 26 15:02:36 2011 +0200
@@ -1535,6 +1535,33 @@
     
     delete this.storedFocusItem;
     delete this.storedSelectionRange;    
+  },
+
+  destroy: function () {
+    var i, items = this.getItems(), len = items.length, ds, dataSources = [];
+
+    // caching reference to all DS of Items
+    for (i = 0; i < len; i++) {
+      item = items[i];
+      ds = items && (item.dataSource || item.optionDataSource);
+
+      if(ds) {
+        dataSources.push(ds);
+      }
+    }
+
+    this.Super('destroy', arguments);
+
+    len = dataSources.length;
+
+    // Destroying DS not managed by DynamicForm.destroy
+    for(i = 0; i < len; i++) {
+      ds = dataSources[i];
+      if(ds) {
+        ds.destroy();
+        ds = null;
+      }
+    }
   }
 };
 
diff -r 90094abfaff9 -r cff2f670c700 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Fri Aug 26 09:39:52 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/grid/ob-view-grid.js
     Fri Aug 26 15:02:36 2011 +0200
@@ -221,7 +221,7 @@
     }
   },
 
-  initWidget: function(){
+  initWidget: function () {
     var i;
     
     // make a copy of the dataProperties otherwise we get 
@@ -290,19 +290,41 @@
     '\'].clearFilter();" class="OBLinkButtonItem">' +
     OB.I18N.getLabel('OBUIAPP_GridClearFilter') +
     '</span>';
-    
+
     return ret;
   },
 
   // destroy the context menu also
   // see why this needs to be done in the 
   // documentation of canvas.contextMenu in Canvas.js
-  destroy: function() {
+  destroy: function () {
+    var i, field, fields = this.getFields(), len = fields.length, ds, 
dataSources = [];
+
+    for(i = 0; i < len; i++) {
+      field = fields[i];
+      editorProperties = field && field.editorProperties;
+      ds = editorProperties && editorProperties.optionDataSource;
+      if(ds) {
+        dataSources.push(ds);
+      }
+    }
+
     if (this.contextMenu) {
       this.contextMenu.destroy();
       this.contextMenu = null;
     }
+
     this.Super('destroy', arguments);
+
+    len = dataSources.length;
+
+    for(i = 0; i < len; i++) {
+      ds = dataSources[i];
+      if(ds) {
+        ds.destroy();
+        ds = null;
+      }
+    }
   },
   
   setData: function(data) {
diff -r 90094abfaff9 -r cff2f670c700 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
--- 
a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
      Fri Aug 26 09:39:52 2011 +0200
+++ 
b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
      Fri Aug 26 15:02:36 2011 +0200
@@ -261,26 +261,6 @@
   setValueInField: function(){
     this.selector.setValueFromRecord(this.selectorGrid.getSelectedRecord(), 
true);
     this.hide();
-  },
-
-  destroy: function () {
-    // Destroy the selectorGrid to avoid memory leaks
-    if(this.selectorGrid) {
-      if(this.selectorGrid.dataSource &&
-         this.selector.form.destroyItemObjects) {
-        this.selectorGrid.dataSource.destroy();
-        this.selectorGrid.dataSource = null;
-      }
-      this.selectorGrid.destroy();
-      this.selectorGrid = null;
-    }
-
-    if(this.dataSource && this.selector.form.destroyItemObjects) {
-      this.dataSource.destroy();
-      this.dataSource = null;
-    }
-
-    this.Super('destroy', arguments);
   }
 });
 
@@ -634,14 +614,6 @@
       this.selectorWindow.destroy();
       this.selectorWindow = null;
     }
-
-    // Only destroy the optionDataSource if is allowed by the form
-    if(this.form.destroyItemObjects) {
-      if(this.optionDataSource) {
-        this.optionDataSource.destroy();
-        this.optionDataSource = null;
-      }
-    }
     this.Super('destroy', arguments);
   }
 });
@@ -819,14 +791,6 @@
       this.selectorWindow.destroy();
       this.selectorWindow = null;
     }
-
-    // Only destroy the optionDataSource if is allowed by the form
-    if(this.form.destroyItemObjects) {
-      if(this.optionDataSource) {
-        this.optionDataSource.destroy();
-        this.optionDataSource = null;
-      }
-    }
     this.Super('destroy', arguments);
   }
 });

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to