From 934f413c1fe5bd381f7857c2c852e0c0dec42726 Mon Sep 17 00:00:00 2001 From: "Guillaume (gdi)" Date: Mon, 7 Nov 2022 09:51:30 +0000 Subject: [PATCH] [FIX] web_editor: do not update the options when destroying them Since [1] it is visible that there is a race condition in the editor. The race condition was caused by a call for an update of the option visibility during the save, but the options may be in the destruction process. This commit prevents the visibility of the options from being updated when the option destruction process begins. Before 16.0 (the merge of the frontend into the backend) the bug was easily visible by following these steps: - Drop 2 times the image - text block on a page - Drop a popup block - Save => During the save, a traceback occurs. From 16.0 the race condition is more difficult to see but we still need this fix because the problem is still there. Note: this forward-port commit took time to get merged in master. Meanwhile, two fixes related to it were merged in stable. The first one already reached master a while ago ([2]) but had thus no effect as was relying on this particular commit here. This is actually great as [2] introduced a big mass mailing bug, fixed by the second fix which is yet to be forward-ported to master. That one has actually been put as this current commit's parent so that [2] is fixed before it can create the mass mailing bug. [1]: https://github.com/odoo/odoo/commit/686e011f9b54bcfe93cc22db24435d2ca9213664 [2]: https://github.com/odoo/odoo/commit/6bf3823c2996af4ec0534ff69471887ac43a8ddf Related to opw-2971181 X-original-commit: 47cdb15082f774da0aa07e289361445ddc3a48f1 Part-of: odoo/odoo#107387 Co-authored-by: xO-Tx --- addons/web_editor/static/src/js/editor/snippets.editor.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 0a8a53216e1..ea88eb34da0 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1546,6 +1546,10 @@ var SnippetEditor = Widget.extend({ * @param {OdooEvent} ev */ _onSnippetOptionVisibilityUpdate: function (ev) { + if (this.options.wysiwyg.isSaving()) { + // Do not update the option visibilities if we are destroying them. + return; + } ev.data.show = this._toggleVisibilityStatus(ev.data.show); }, /** @@ -4051,6 +4055,10 @@ var SnippetsMenu = Widget.extend({ * @param {OdooEvent} ev */ _onSnippetOptionVisibilityUpdate: async function (ev) { + if (this.options.wysiwyg.isSaving()) { + // Do not update the option visibilities if we are destroying them. + return; + } if (!ev.data.show) { await this._activateSnippet(false); }