[FIX] web: view list: ensure that the mutex of synchronized method `reload_content` is always released.

bzr revid: chs@openerp.com-20131122131037-sqxs1fdh4al32eh2
This commit is contained in:
Christophe Simonis 2013-11-22 14:10:37 +01:00
parent 56d579b1e0
commit e555872646
1 changed files with 29 additions and 14 deletions

View File

@ -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 () {