summaryrefslogtreecommitdiff
path: root/addons/bus/static/src
diff options
context:
space:
mode:
authorVincent Schippefilt <vsc@odoo.com>2019-02-20 09:28:49 +0000
committerAaron Bohy <aab@odoo.com>2019-03-05 09:00:40 +0000
commit646db1e1b829914d179ec17bca1fc7fbfb268d2d (patch)
tree8cdb7f59be2d0a526cd762f8d518da4e504b10d4 /addons/bus/static/src
parent9b498247c966d1da5a04788b1955fadb6f6cb7bd (diff)
[FIX] bus: longpolling clears its handlers correctly
`this._id` is overriden by the crosstab_bus, so the event handlers weren't unbound at destroy. Manual forwardport of odoo/odoo#31578, as we need this for another branch, in which it makes tests fail. closes odoo/odoo#31579 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
Diffstat (limited to 'addons/bus/static/src')
-rw-r--r--addons/bus/static/src/js/longpolling_bus.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/addons/bus/static/src/js/longpolling_bus.js b/addons/bus/static/src/js/longpolling_bus.js
index 50058bc8ae4..83f2b0676ef 100644
--- a/addons/bus/static/src/js/longpolling_bus.js
+++ b/addons/bus/static/src/js/longpolling_bus.js
@@ -32,30 +32,33 @@ var LongpollingBus = Bus.extend(ServicesMixin, {
init: function (parent, params) {
this._super.apply(this, arguments);
this._id = _.uniqueId('bus');
+
+ // the _id is modified by crosstab_bus, so we can't use it to unbind the events in the destroy.
+ this._longPollingBusId = this._id;
this._options = {};
this._channels = [];
// bus presence
this._lastPresenceTime = new Date().getTime();
- $(window).on("focus." + this._id, this._onFocusChange.bind(this, {focus: true}));
- $(window).on("blur." + this._id, this._onFocusChange.bind(this, {focus: false}));
- $(window).on("unload." + this._id, this._onFocusChange.bind(this, {focus: false}));
+ $(window).on("focus." + this._longPollingBusId, this._onFocusChange.bind(this, {focus: true}));
+ $(window).on("blur." + this._longPollingBusId, this._onFocusChange.bind(this, {focus: false}));
+ $(window).on("unload." + this._longPollingBusId, this._onFocusChange.bind(this, {focus: false}));
- $(window).on("click." + this._id, this._onPresence.bind(this));
- $(window).on("keydown." + this._id, this._onPresence.bind(this));
- $(window).on("keyup." + this._id, this._onPresence.bind(this));
+ $(window).on("click." + this._longPollingBusId, this._onPresence.bind(this));
+ $(window).on("keydown." + this._longPollingBusId, this._onPresence.bind(this));
+ $(window).on("keyup." + this._longPollingBusId, this._onPresence.bind(this));
},
/**
* @override
*/
destroy: function () {
this.stopPolling();
- $(window).off("focus." + this._id);
- $(window).off("blur." + this._id);
- $(window).off("unload." + this._id);
- $(window).off("click." + this._id);
- $(window).off("keydown." + this._id);
- $(window).off("keyup." + this._id);
+ $(window).off("focus." + this._longPollingBusId);
+ $(window).off("blur." + this._longPollingBusId);
+ $(window).off("unload." + this._longPollingBusId);
+ $(window).off("click." + this._longPollingBusId);
+ $(window).off("keydown." + this._longPollingBusId);
+ $(window).off("keyup." + this._longPollingBusId);
this._super();
},
//--------------------------------------------------------------------------