[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:
parent
97da93d3a1
commit
79a24bd46e
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue