From 18e4b34b7009f3f135609e0e4b6525cf88a08752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 20 Jan 2021 09:18:19 +0000 Subject: [PATCH] [FIX] web: protect graph code against destruction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) Signed-off-by: Géry Debongnie (ged) --- addons/web/static/src/js/views/graph/graph_controller.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/graph/graph_controller.js b/addons/web/static/src/js/views/graph/graph_controller.js index 2f2919af272..b7bb10ea0c2 100644 --- a/addons/web/static/src/js/views/graph/graph_controller.js +++ b/addons/web/static/src/js/views/graph/graph_controller.js @@ -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);