summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/thread_field.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-07-11 15:53:36 +0200
committerGéry Debongnie <ged@odoo.com>2017-07-12 13:41:51 +0200
commit9ee00dd265457948e0cfc8bdcca2a34064191d0c (patch)
treee89a3aedba71319037c4fe2ded53d8581a13206f /addons/mail/static/src/js/thread_field.js
parented2a77e50e94d957caca6dea309d84c55908cf93 (diff)
[FIX] mail: prevent crash when chat system is not ready
When a chatter is created, appended, and destroyed before being ready, bad things could happen. This is because the code in start/other deferred was executed regardless if the widget was still alive. And, some mechanisms, such as _getBus, depends on the event system. If the widget is destroyed, it will be remove from the component tree and such functions will then return undefined. To protect agains those issues, we simply make sure that the deferred are only resolved when the widget is still alive.
Diffstat (limited to 'addons/mail/static/src/js/thread_field.js')
-rw-r--r--addons/mail/static/src/js/thread_field.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/mail/static/src/js/thread_field.js b/addons/mail/static/src/js/thread_field.js
index 481dc49af36..0d7635cae8b 100644
--- a/addons/mail/static/src/js/thread_field.js
+++ b/addons/mail/static/src/js/thread_field.js
@@ -21,7 +21,7 @@ var ThreadField = AbstractField.extend(chat_mixin, {
this.msgIDs = this.value.res_ids;
},
willStart: function () {
- return this._chatReady();
+ return this.alive(this._chatReady());
},
start: function () {
var self = this;
@@ -43,7 +43,7 @@ var ThreadField = AbstractField.extend(chat_mixin, {
var def1 = this.thread.appendTo(this.$el);
var def2 = this._super.apply(this, arguments);
- return $.when(def1, def2).then(function () {
+ return this.alive($.when(def1, def2)).then(function () {
// unwrap the thread to remove an unnecessary level on div
self.setElement(self.thread.$el);