From 79a24bd46ee4b4d961afbfea78e746f754e24ed9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 28 Jun 2011 16:09:07 +0200 Subject: [PATCH] [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 --- addons/base/static/src/js/chrome.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/base/static/src/js/chrome.js b/addons/base/static/src/js/chrome.js index 556c715d339..12f9bc2e7ae 100644 --- a/addons/base/static/src/js/chrome.js +++ b/addons/base/static/src/js/chrome.js @@ -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