Related to issue 18227: Closing a tab doesn't release all objects
authorMartin Taal <martin.taal@openbravo.com>
Fri, 09 Sep 2011 17:46:45 +0200
changeset 13716 3d4180abc6b1
parent 13715 28db0b3614a1
child 13717 b4f5d5f4ba25
Related to issue 18227: Closing a tab doesn't release all objects
Sometimes datasources are connected to canvasitems, also release these
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
--- a/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Fri Sep 09 17:45:42 2011 +0200
+++ b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js	Fri Sep 09 17:46:45 2011 +0200
@@ -31,6 +31,22 @@
 // NOTE: disabled as now timezone is send from the client to the server
 // Time.setDefaultDisplayTimezone(0);
 
+isc.Canvas.addProperties({
+  // make sure that the datasources are also destroyed
+  _original_destroy: isc.Canvas.getPrototype().destroy,
+  destroy: function() {
+    if (this.optionDataSource && !this.optionDataSource.potentiallyShared) {
+      this.optionDataSource.destroy();
+      this.optionDataSource = null;
+    }
+    if (this.dataSource && !this.dataSource.potentiallyShared) {
+      this.dataSource.destroy();
+      this.dataSource = null;
+    }
+    this._original_destroy();
+  }
+});
+
 //Let the click on an ImgButton and Button fall through to its action method 
 isc.ImgButton.addProperties({
   click: function() {