details:   https://code.openbravo.com/erp/devel/pi/rev/0722842665d9
changeset: 13545:0722842665d9
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Wed Aug 17 16:10:48 2011 +0200
summary:   Issue 18227: Added a flag to know when to destroy associated objects
When seting the DataSource at form level, the fields are recreated. The
destroy method of an item needs to clean all associated objects just if flag
destroyItemObjects is true

details:   https://code.openbravo.com/erp/devel/pi/rev/0c139e47fb21
changeset: 13546:0c139e47fb21
user:      Iván Perdomo <ivan.perdomo <at> openbravo.com>
date:      Wed Aug 17 16:16:06 2011 +0200
summary:   Issue 18227: Clean the associated datasource and grid
Clean the associated optionDataSource and dataSource when the form declares
that is possible through the flag destroyItemObjects

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
    |   6 +-
 
modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
 |  38 ++++++++-
 2 files changed, 36 insertions(+), 8 deletions(-)

diffs (94 lines):

diff -r 2b8cac5023a8 -r 0c139e47fb21 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Wed Aug 17 15:53:40 2011 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/main/ob-standard-view.js
 Wed Aug 17 16:16:06 2011 +0200
@@ -179,7 +179,7 @@
   
   isShowingForm: false,
   isEditingGrid: false,
-  
+
   initWidget: function(properties){
     this.messageBar = isc.OBMessageBar.create({
       visibility: 'hidden',
@@ -255,8 +255,12 @@
     }
     
     if (this.viewForm) {
+      // setDataSource executes setFields which replaces the current fields
+      // We don't want to destroy the associated DataSource objects
+      this.viewForm.destroyItemObjects = false;
       this.viewForm.setDataSource(this.dataSource, this.viewForm.fields);
       this.viewForm.isViewForm = true;
+      this.viewForm.destroyItemObjects = true;
     }
     
     if (this.isRootView) {
diff -r 2b8cac5023a8 -r 0c139e47fb21 
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
      Wed Aug 17 15:53:40 2011 +0200
+++ 
b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js
      Wed Aug 17 16:16:06 2011 +0200
@@ -269,6 +269,12 @@
       this.selectorGrid.destroy();
       this.selectorGrid = null;
     }
+
+    if(this.dataSource) {
+      this.dataSource.destroy();
+      this.dataSource = null;
+    }
+
     this.Super('destroy', arguments);
   }
 });
@@ -297,7 +303,11 @@
     title: OB.I18N.getLabel('OBUISC_Identifier'),
     name: OB.Constants.IDENTIFIER
   }],
-  
+
+  // Do not fetch data upon creation
+  // 
http://www.smartclient.com/docs/8.1/a/b/c/go.html#attr..ComboBoxItem.optionDataSource
+  fetchMissingValues: false,
+
   autoFetchData: false,
   showPickerIcon: true,
   validateOnChange: true,
@@ -615,9 +625,16 @@
 
   destroy: function () {
     // Explicitly destroy the selector window to avoid memory leaks
-    if(this.selectorWindow) {
-      this.selectorWindow.destroy();
-      this.selectorWindow = null;
+    if(this.form.destroyItemObjects) {
+      if(this.selectorWindow) {
+        this.selectorWindow.destroy();
+        this.selectorWindow = null;
+      }
+
+      if(this.optionDataSource) {
+        this.optionDataSource.destroy();
+        this.optionDataSource = null;
+      }
     }
     this.Super('destroy', arguments);
   }
@@ -792,9 +809,16 @@
 
   destroy: function () {
     // Explicitly destroy the selector window to avoid memory leaks
-    if(this.selectorWindow) {
-      this.selectorWindow.destroy();
-      this.selectorWindow = null;
+    if(this.form.destroyItemObjects) {
+      if(this.selectorWindow) {
+        this.selectorWindow.destroy();
+        this.selectorWindow = null;
+      }
+
+      if(this.optionDataSource) {
+        this.optionDataSource.destroy();
+        this.optionDataSource = null;
+      }
     }
     this.Super('destroy', arguments);
   }

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to