[FIX] removal of unique() callbacks from callback chains

Array.prototype.pop() does *not* take a parameter, it always removes the last item of the array.

To remove items in the middle of an array, Array.prototype.splice(index, 1) has to be used.

This fixes an issue where adding a unique non-last callback (either added as non-last, or with other stuff added after it) would result in nonsensical behavior

bzr revid: xmo@openerp.com-20110628140907-5sch98gmwcnpvk3t
This commit is contained in:
Xavier Morel 2011-06-28 16:09:07 +02:00
parent 97da93d3a1
commit 79a24bd46e
1 changed files with 2 additions and 2 deletions

View File

@ -11,8 +11,8 @@ openerp.base.callback = function(obj, method) {
for(var i = 0; i < callback.callback_chain.length; i++) {
var c = callback.callback_chain[i];
if(c.unique) {
// al: obscure but shortening C-style hack, sorry
callback.callback_chain.pop(i--);
callback.callback_chain.splice(i, 1);
i -= 1;
}
r = c.callback.apply(c.self, c.args.concat(args));
// TODO special value to stop the chain