details:   https://code.openbravo.com/erp/devel/pi/rev/253b5864e293
changeset: 20306:253b5864e293
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri May 10 08:57:18 2013 +0200
summary:   Related to issue 23761: Fixed leaks when Alerts iwndow is opened

details:   https://code.openbravo.com/erp/devel/pi/rev/2065f7a45897
changeset: 20307:2065f7a45897
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri May 10 08:58:02 2013 +0200
summary:   Related to issue 23761: Fixed leaks when Help menu is opened

details:   https://code.openbravo.com/erp/devel/pi/rev/752359630143
changeset: 20308:752359630143
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri May 10 08:58:48 2013 +0200
summary:   Related to issue 23761: Fixed leaks when the quick launch menu is 
opened

details:   https://code.openbravo.com/erp/devel/pi/rev/58ca94d1bf65
changeset: 20309:58ca94d1bf65
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri May 10 09:27:29 2013 +0200
summary:   Related to bug 23761: Fixed leaks in Recent Views menu when a window 
is opened

details:   https://code.openbravo.com/erp/devel/pi/rev/590cb3340e9a
changeset: 20310:590cb3340e9a
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri May 10 09:50:14 2013 +0200
summary:   Related to issue 23761: Fixed destroyAndRemoveMembers function

There was a bug in the destroyAndRemoveMembers. This function is used to 
destroy and remove a list of members from a layout. When this function was used 
~50%
of the members of the layout where not being destroyed, causing leaks.

diffstat:

 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-grid.js
            |   8 +
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-management-view.js
 |  46 ++++++++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-help-about-widget.js
               |  55 ++++++---
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quick-launch.js
                    |   3 +
 
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
                                          |  10 +-
 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
              |  17 ++-
 6 files changed, 114 insertions(+), 25 deletions(-)

diffs (262 lines):

diff -r c8f69b3d8d6c -r 590cb3340e9a 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-grid.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-grid.js
        Thu May 09 15:56:54 2013 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-grid.js
        Fri May 10 09:50:14 2013 +0200
@@ -126,6 +126,14 @@
     this.Super('initWidget', arguments);
   },
 
+  destroy: function () {
+    if (this.contextMenu) {
+      this.contextMenu.destroy();
+      this.contextMenu = null;
+    }
+    this.Super('destroy', arguments);
+  },
+
   setDataSource: function (ds) {
     this.Super('setDataSource', [ds, this.gridFields]);
     // Some properties need to be set when the datasource is loaded to avoid 
errors when form is
diff -r c8f69b3d8d6c -r 590cb3340e9a 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-management-view.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-management-view.js
     Thu May 09 15:56:54 2013 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/alert-management/ob-alert-management-view.js
     Fri May 10 09:50:14 2013 +0200
@@ -195,6 +195,52 @@
     this.sectionStack.addSection(this.sections.Solved);
   },
 
+  destroy: function () {
+    if (this.grids) {
+      if (this.grids.New) {
+        this.grids.New.destroy();
+        this.grids.New = null;
+      }
+      if (this.grids.Acknowledged) {
+        this.grids.Acknowledged.destroy();
+        this.grids.Acknowledged = null;
+      }
+      if (this.grids.Suppressed) {
+        this.grids.Suppressed.destroy();
+        this.grids.Suppressed = null;
+      }
+      if (this.grids.Solved) {
+        this.grids.Solved.destroy();
+        this.grids.Solved = null;
+      }
+    }
+    if (this.NewAcknowledged) {
+      this.NewAcknowledged.destroy();
+      this.NewAcknowledged = null;
+    }
+    if (this.NewSuppressed) {
+      this.NewSuppressed.destroy();
+      this.NewSuppressed = null;
+    }
+    if (this.AcknowledgedNew) {
+      this.AcknowledgedNew.destroy();
+      this.AcknowledgedNew = null;
+    }
+    if (this.AcknowledgedSuppressed) {
+      this.AcknowledgedSuppressed.destroy();
+      this.AcknowledgedSuppressed = null;
+    }
+    if (this.SuppressedNew) {
+      this.SuppressedNew.destroy();
+      this.SuppressedNew = null;
+    }
+    if (this.SuppressedAcknowledged) {
+      this.SuppressedAcknowledged.destroy();
+      this.SuppressedAcknowledged = null;
+    }
+    this.Super('destroy', arguments);
+  },
+
   moveToStatus: function (alertIDs, oldStatus, newStatus) {
     var post = {
       'eventType': 'moveToStatus',
diff -r c8f69b3d8d6c -r 590cb3340e9a 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-help-about-widget.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-help-about-widget.js
   Thu May 09 15:56:54 2013 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-help-about-widget.js
   Fri May 10 09:50:14 2013 +0200
@@ -34,6 +34,10 @@
 
   // Set to empty to prevent an icon from being displayed on the button.
   src: '',
+  aboutLink: null,
+  helpLink: null,
+  dummyFirstField: null,
+  dummyLastField: null,
 
   showTitle: true,
 
@@ -64,25 +68,20 @@
   beforeShow: function () {
     // determine if the help should be displayed or not
     var tabPane = null,
-        aboutLink = null,
-        helpLink = null,
-        helpView = null,
-        dummyFirstField = null,
-        dummyLastField = null;
-
-    dummyFirstField = isc.OBFocusButton.create({
+        helpView = null;
+    this.dummyFirstField = isc.OBFocusButton.create({
       getFocusTarget: function () {
         return 
isc.OBQuickRun.currentQuickRun.members[0].members[isc.OBQuickRun.currentQuickRun.members[0].getMembers().length
 - 2];
       }
     });
 
-    dummyLastField = isc.OBFocusButton.create({
+    this.dummyLastField = isc.OBFocusButton.create({
       getFocusTarget: function () {
         return isc.OBQuickRun.currentQuickRun.members[0].members[1];
       }
     });
 
-    aboutLink = isc.OBHelpAboutLinkButton.create({
+    this.aboutLink = isc.OBHelpAboutLinkButton.create({
       name: 'aboutLink',
       title: OB.I18N.getLabel('UINAVBA_About'),
       keyPress: function () {
@@ -100,7 +99,7 @@
       }
     });
 
-    helpLink = isc.OBHelpAboutLinkButton.create({
+    this.helpLink = isc.OBHelpAboutLinkButton.create({
       name: 'helpLink',
       title: OB.I18N.getLabel('UINAVBA_Help'),
       keyPress: function () {
@@ -129,19 +128,41 @@
       
this.members[0].destroyAndRemoveMembers(this.members[0].getMembers().duplicate());
     }
     if (!tabPane) {
-      this.members[0].addMembers([aboutLink]);
+      this.members[0].addMembers([this.aboutLink]);
     } else {
       helpView = tabPane.getHelpView();
       if (!helpView) {
-        this.members[0].addMembers([aboutLink]);
+        this.members[0].addMembers([this.aboutLink]);
       } else {
-        this.members[0].addMembers([helpLink, aboutLink]);
+        this.members[0].addMembers([this.helpLink, this.aboutLink]);
       }
     }
-    this.members[0].addMembers(dummyFirstField, 0);
-    this.members[0].addMembers(dummyLastField, 
this.members[0].getMembers().length);
-    
OB.TestRegistry.register('org.openbravo.client.application.HelpAbout.HelpLink', 
helpLink);
-    
OB.TestRegistry.register('org.openbravo.client.application.HelpAbout.AboutLink',
 aboutLink);
+    this.members[0].addMembers(this.dummyFirstField, 0);
+    this.members[0].addMembers(this.dummyLastField, 
this.members[0].getMembers().length);
+    
OB.TestRegistry.register('org.openbravo.client.application.HelpAbout.HelpLink', 
this.helpLink);
+    
OB.TestRegistry.register('org.openbravo.client.application.HelpAbout.AboutLink',
 this.aboutLink);
+  },
+
+  doHide: function () {
+    if (this.aboutLink) {
+      this.aboutLink.destroy();
+      this.aboutLink = null;
+      this.members[0].destroyAndRemoveMembers(this.aboutLink);
+    }
+    if (this.helpLink) {
+      this.helpLink.destroy();
+      this.helpLink = null;
+      this.members[0].destroyAndRemoveMembers(this.helpLink);
+    }
+    if (this.dummyFirstField) {
+      this.dummyFirstField.destroy();
+      this.dummyFirstField = null;
+    }
+    if (this.dummyLastField) {
+      this.dummyLastField.destroy();
+      this.dummyLastField = null;
+    }
+    this.Super('doHide', arguments);
   },
 
   members: [isc.VLayout.create({
diff -r c8f69b3d8d6c -r 590cb3340e9a 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quick-launch.js
--- 
a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quick-launch.js
        Thu May 09 15:56:54 2013 +0200
+++ 
b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/navbar/ob-quick-launch.js
        Fri May 10 09:50:14 2013 +0200
@@ -120,6 +120,9 @@
         OB.Utilities.openDirectTab(params.tabId, params.recordId, 
params.command);
       }
     }
+    if (this.members[1].getMembers()) {
+      
this.members[1].destroyAndRemoveMembers(this.members[1].getMembers().duplicate());
+    }
 
     this.Super('doHide', arguments);
   },
diff -r c8f69b3d8d6c -r 590cb3340e9a 
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
--- 
a/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
      Thu May 09 15:56:54 2013 +0200
+++ 
b/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-myopenbravo.js
      Fri May 10 09:50:14 2013 +0200
@@ -436,7 +436,7 @@
 
   setRecentList: function (layout) {
     var recentList, newRecent, handleClickFunction, recentIndex = 0,
-        recent, lbl, newIcon, entryLayout, icon;
+        recent, lbl, newIcon, entryLayout, icon, destroyFunction;
 
     // start with a fresh content
     layout.destroyAndRemoveMembers(layout.members);
@@ -453,6 +453,11 @@
         }
       };
 
+      destroyFunction = function () {
+        this.destroyAndRemoveMembers(this.members);
+        this.Super('destroy', arguments);
+      };
+
       for (; recentIndex < recentList.length; recentIndex++) {
         if (recentList[recentIndex]) {
           recent = recentList[recentIndex];
@@ -492,7 +497,8 @@
 
           entryLayout = isc.HLayout.create({
             defaultLayoutAlign: 'center',
-            width: '100%'
+            width: '100%',
+            destroy: destroyFunction
           });
           entryLayout.addMember(lbl);
           // if a standard window then show the new icon
diff -r c8f69b3d8d6c -r 590cb3340e9a 
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
  Thu May 09 15:56:54 2013 +0200
+++ 
b/modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
  Fri May 10 09:50:14 2013 +0200
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2011-2012 Openbravo SLU
+ * All portions are Copyright (C) 2011-2013 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -99,16 +99,21 @@
 isc.Layout.addProperties({
 
   destroyAndRemoveMembers: function (toDestroy) {
-    var i;
+    var i, len, toDestroyCopy, nextIndex = 0;
     if (!isc.isA.Array(toDestroy)) {
       toDestroy = [toDestroy];
     }
-    for (i = 0; i < toDestroy.length; i++) {
-      if (toDestroy[i] && toDestroy[i].destroy) {
-        toDestroy[i].destroy();
+    toDestroyCopy = isc.shallowClone(toDestroy);
+    len = toDestroy.length;
+    for (i = 0; i < len; i++) {
+      if (toDestroy[nextIndex] && toDestroy[nextIndex].destroy) {
+        toDestroy[nextIndex].destroy();
+      }
+      if (toDestroy.length === len) {
+        nextIndex = nextIndex + 1;
       }
     }
-    this.removeMembers(toDestroy);
+    this.removeMembers(toDestroyCopy);
   }
 });
 

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to