From 03ffa1d1c7610e6074caef1eefe962abe0d22b68 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Tue, 8 Feb 2022 16:48:17 +0000 Subject: [PATCH] [FIX] web_editor: prevent traceback on destroy link tools When saving a mailing with the link tools open, link tools' destroy is called after OdooEditor's destroy, causing a traceback when link tools tries to set a history step. task-2733825 closes odoo/odoo#84354 X-original-commit: f565f965fdc15d744efd38cfca9b098e24181e7e Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js | 2 ++ addons/web_editor/static/src/js/wysiwyg/widgets/link_tools.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js index 5612c61dc08..3a3f1ffd058 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -179,6 +179,7 @@ export class OdooEditor extends EventTarget { // -------------- this.document = options.document || document; + this.isDestroyed = false; this.isMobile = matchMedia('(max-width: 767px)').matches; this.isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; @@ -348,6 +349,7 @@ export class OdooEditor extends EventTarget { this._resizeObserver.disconnect(); clearInterval(this._snapshotInterval); this._pluginCall('destroy', []); + this.isDestroyed = true; } sanitize() { diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/link_tools.js b/addons/web_editor/static/src/js/wysiwyg/widgets/link_tools.js index 6a167a7ca7b..73c407d4f43 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/link_tools.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link_tools.js @@ -66,7 +66,9 @@ const LinkTools = Link.extend({ this.$button.removeClass('active'); this.options.wysiwyg.odooEditor.observerActive(); this.applyLinkToDom(this._getData()); - this.options.wysiwyg.odooEditor.historyStep(); + if (!this.options.wysiwyg.odooEditor.isDestroyed) { + this.options.wysiwyg.odooEditor.historyStep(); + } this._observer.disconnect(); this._super(...arguments); },