summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2012-10-18 11:51:32 +0200
committerniv-openerp <nicolas.vanhoren@openerp.com>2012-10-18 11:51:32 +0200
commita077619c9021db23ecbd3985d33d8fa37b895ecb (patch)
treef800c635522451b03f10cc53414821a99ab48cc4 /addons/web/static/src
parent508c11d4a43576c87026f827526f7e9c3d564369 (diff)
[FIX] memory leak in event dispatcher
bzr revid: nicolas.vanhoren@openerp.com-20121018095132-3ew3rbkjfwzgp5r1
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/corelib.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/addons/web/static/src/js/corelib.js b/addons/web/static/src/js/corelib.js
index 8c38724b1d5..7f4f8c0d6ca 100644
--- a/addons/web/static/src/js/corelib.js
+++ b/addons/web/static/src/js/corelib.js
@@ -291,6 +291,17 @@ var Events = instance.web.Class.extend({
return this;
},
+ callbackList: function() {
+ var lst = [];
+ _.each(this._callbacks || {}, function(el, eventName) {
+ var node = el;
+ while ((node = node.next) && node.next) {
+ lst.push([eventName, node.callback, node.context]);
+ }
+ });
+ return lst;
+ },
+
trigger : function(events) {
var event, node, calls, tail, args, all, rest;
if (!(calls = this._callbacks))
@@ -369,9 +380,9 @@ instance.web.EventDispatcherMixin = _.extend({}, instance.web.ParentedMixin, {
event.source.__edispatcherEvents.off(event.name, event.func, self);
});
this.__edispatcherRegisteredEvents = [];
- if(!this.__edispatcherEvents) {
- debugger;
- }
+ _.each(this.__edispatcherEvents.callbackList(), function(cal) {
+ this.off(cal[0], cal[2], cal[1]);
+ }, this);
this.__edispatcherEvents.off();
instance.web.ParentedMixin.destroy.call(this);
}