[FIX] web: protect graph code against destruction

The graph controller _attachDropdownComponents is not safe: it assumes
that it is not destroyed whenever it manipulates its own measureMenu sub
component, but it is certainly not guaranteed. This commit protects
against this possibility.

Also, at the same time, we return the promise in updateButtons, so it
can be chained if necessary (which is useful in the Dashboard view for
example).  This is a new problem, because with the change to Owl, we go
through multiple phases of rendering.

closes odoo/odoo#64820

X-original-commit: 2dcf251c2d7a8bd43193e3e0b715ef3692d4e00f
Related: odoo/enterprise#15869
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
This commit is contained in:
Géry Debongnie
2021-01-20 15:51:36 +00:00
parent 50eff609a0
commit 18e4b34b70
@@ -165,7 +165,7 @@ var GraphController = AbstractController.extend({
.toggleClass('active', !!state.orderBy);
if (this.withButtons) {
this._attachDropdownComponents();
return this._attachDropdownComponents();
}
},
@@ -180,6 +180,9 @@ var GraphController = AbstractController.extend({
*/
async _attachDropdownComponents() {
await Promise.all(this.buttonDropdownPromises);
if (this.isDestroyed()) {
return;
}
const actionsContainer = this.$buttons[0];
// Attach "measures" button
actionsContainer.appendChild(this.measureMenu.el);