From df3c6b750249d33102cea4f1c0003df0b3fbb87c Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 11 Apr 2014 18:24:26 +0200 Subject: [PATCH] [FIX] web: do not try to close a destroyed dialog. trigger "closing" signal on close by top-right "X" button bzr revid: chs@openerp.com-20140411162426-60bfybim5aqojsxx --- addons/web/static/src/js/chrome.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index e4a985bc512..cc65900a1bc 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -198,6 +198,8 @@ instance.web.Dialog = instance.web.Widget.extend({ if (options.height === 'auto' && options.max_height) { this.$el.css({ 'max-height': options.max_height, 'overflow-y': 'auto' }); } + var self = this; + this.$el.on('dialogclose', function() { self.close(); }); this.dialog_inited = true; var res = this.start(); return res; @@ -206,9 +208,11 @@ instance.web.Dialog = instance.web.Widget.extend({ Closes the popup, if destroy_on_close was passed to the constructor, it is also destroyed. */ close: function(reason) { - if (this.dialog_inited && this.$el.is(":data(dialog)")) { + if (this.dialog_inited) { this.trigger("closing", reason); - this.$el.dialog('close'); + if (this.$el.is(":data(dialog)")) { // may have been destroyed by closing signal + this.$el.dialog('close'); + } } }, _closing: function() {