From 4f5fc6ee552e5f2edca6401d04761a3c19797dc7 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 6 Feb 2018 11:17:06 +0100 Subject: [PATCH] [FIX] web: properly set parent when using mixins The parentedMixin doesn't automatically set the parent, so when this mixin is used, the parent must be set manually. This wasn't done at several places, and thus those elements weren't destroyed with their actual parent. In master, we should probably make the ParentedMixin set the parent itself. --- addons/mail/static/src/js/chat_manager.js | 2 +- addons/point_of_sale/static/src/js/devices.js | 3 ++- addons/pos_restaurant/static/src/js/multiprint.js | 3 ++- addons/web/static/src/js/_deprecated/data.js | 1 + addons/web/static/src/js/chrome/control_panel.js | 2 +- addons/web/static/src/js/core/bus.js | 5 +++-- addons/web/static/src/js/core/session.js | 3 ++- 7 files changed, 12 insertions(+), 7 deletions(-) diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index f7aaf73637e..2a64dcda828 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -611,7 +611,7 @@ var ChatManager = Class.extend(Mixins.EventDispatcherMixin, ServicesMixin, { Mixins.EventDispatcherMixin.init.call(this); this.setParent(parent); - this.bus = new Bus(); + this.bus = new Bus(this); this.bus.on('client_action_open', null, function (open) { client_action_open = open; }); diff --git a/addons/point_of_sale/static/src/js/devices.js b/addons/point_of_sale/static/src/js/devices.js index bf11db31bf2..f06abc15c66 100644 --- a/addons/point_of_sale/static/src/js/devices.js +++ b/addons/point_of_sale/static/src/js/devices.js @@ -93,8 +93,9 @@ var JobQueue = function(){ var ProxyDevice = core.Class.extend(mixins.PropertiesMixin,{ init: function(parent,options){ - mixins.PropertiesMixin.init.call(this,parent); + mixins.PropertiesMixin.init.call(this); var self = this; + this.setParent(parent); options = options || {}; this.pos = parent; diff --git a/addons/pos_restaurant/static/src/js/multiprint.js b/addons/pos_restaurant/static/src/js/multiprint.js index dac0a906850..1a135bdfe03 100644 --- a/addons/pos_restaurant/static/src/js/multiprint.js +++ b/addons/pos_restaurant/static/src/js/multiprint.js @@ -11,7 +11,8 @@ var QWeb = core.qweb; var Printer = core.Class.extend(mixins.PropertiesMixin,{ init: function(parent,options){ - mixins.PropertiesMixin.init.call(this,parent); + mixins.PropertiesMixin.init.call(this); + this.setParent(parent); options = options || {}; var url = options.url || 'http://localhost:8069'; this.connection = new Session(undefined,url, { use_cors: true}); diff --git a/addons/web/static/src/js/_deprecated/data.js b/addons/web/static/src/js/_deprecated/data.js index 14b3daeb2c6..e13ca14da22 100644 --- a/addons/web/static/src/js/_deprecated/data.js +++ b/addons/web/static/src/js/_deprecated/data.js @@ -314,6 +314,7 @@ var DataSet = Class.extend(mixins.PropertiesMixin, { */ init: function (parent, model, context) { mixins.PropertiesMixin.init.call(this); + this.setParent(parent); this.model = model; this.context = context || {}; this.index = null; diff --git a/addons/web/static/src/js/chrome/control_panel.js b/addons/web/static/src/js/chrome/control_panel.js index 173d91aea25..3c445fd6bcb 100644 --- a/addons/web/static/src/js/chrome/control_panel.js +++ b/addons/web/static/src/js/chrome/control_panel.js @@ -47,7 +47,7 @@ var ControlPanel = Widget.extend({ this.template = template; } - this.bus = new Bus(); + this.bus = new Bus(this); this.bus.on("update", this, this.update); }, /** diff --git a/addons/web/static/src/js/core/bus.js b/addons/web/static/src/js/core/bus.js index bf33c1fe01e..e2b76594946 100644 --- a/addons/web/static/src/js/core/bus.js +++ b/addons/web/static/src/js/core/bus.js @@ -8,8 +8,9 @@ var mixins = require('web.mixins'); * Event Bus used to bind events scoped in the current instance */ return Class.extend(mixins.EventDispatcherMixin, { - init: function() { - mixins.EventDispatcherMixin.init.call(this, parent); + init: function (parent) { + mixins.EventDispatcherMixin.init.call(this); + this.setParent(parent); }, }); diff --git a/addons/web/static/src/js/core/session.js b/addons/web/static/src/js/core/session.js index 670e367be2e..ee9427827ba 100644 --- a/addons/web/static/src/js/core/session.js +++ b/addons/web/static/src/js/core/session.js @@ -28,7 +28,8 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { "override_session" is set to true. */ init: function (parent, origin, options) { - mixins.EventDispatcherMixin.init.call(this, parent); + mixins.EventDispatcherMixin.init.call(this); + this.setParent(parent); options = options || {}; this.module_list = (options.modules && options.modules.slice()) || (window.odoo._modules && window.odoo._modules.slice()) || []; this.server = null;