[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) <dmo@odoo.com>
This commit is contained in:
Antoine Guenet
2022-02-10 15:42:52 +00:00
parent 17c5f29774
commit 03ffa1d1c7
2 changed files with 5 additions and 1 deletions
@@ -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() {
@@ -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);
},