From e5558726465419e4c6dce68601c47325941e15a9 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 22 Nov 2013 14:10:37 +0100 Subject: [PATCH] [FIX] web: view list: ensure that the mutex of synchronized method `reload_content` is always released. bzr revid: chs@openerp.com-20131122131037-sqxs1fdh4al32eh2 --- addons/web/static/src/js/view_list.js | 43 ++++++++++++++++++--------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index b9c789cb6a9..868a218f70e 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -501,23 +501,38 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi self.$el.find('.oe_list_record_selector').prop('checked', false); this.records.reset(); var reloaded = $.Deferred(); - this.$el.find('.oe_list_content').append( - this.groups.render(function () { - if (self.dataset.index == null) { - if (self.records.length) { + + setTimeout(function() { + var $group; + try { + $group = self.groups.render(function () { + // NOTE using == instead of === is wanted. + if (self.dataset.index == null) { // jshint ignore:line + if (self.records.length) { + self.dataset.index = 0; + } + } else if (self.dataset.index >= self.records.length) { self.dataset.index = 0; } - } else if (self.dataset.index >= self.records.length) { - self.dataset.index = 0; - } - self.compute_aggregates(); - reloaded.resolve(); - })); - this.do_push_state({ - page: this.page, - limit: this._limit - }); + self.compute_aggregates(); + }); + } finally { + // ensure that the deferred is always rejected/resolved to quit the + // synchronized block properly. + if (_.isUndefined($group)) { + reloaded.reject(); + } else { + reloaded.resolve(); + self.$el.find('.oe_list_content').append($group); + self.do_push_state({ + page: self.page, + limit: self._limit + }); + } + } + + }, 0); return reloaded.promise(); }), reload: function () {