diff options
| author | Christophe Matthieu <chm@odoo.com> | 2016-09-01 15:26:41 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2016-11-04 14:07:35 +0100 |
| commit | a8e79e960aa962b4b89710918a03a5983bf492c6 (patch) | |
| tree | 92d5dcc5685adf5c49c64d7b8e2d1d644470409c /addons/web/static/src/js/control_panel.js | |
| parent | 3cb337945628ffc243072c93a47f6fc55d0f03fd (diff) | |
[FIX] bus,im_odoo_support, web*: fix various memory leaks
* Tip are never destroyed when change view mode
* unbind methods
* mail: memory leak with unbind methods
* web: memory leak because 'ui-autocomplete' is never destroyed
* web_editor: memory leak for wrong unbind on destroy
* web: memory leak: must remove fileupload handler
* bus: memory leak: correctly debind handlers on window in bus.Bus
* remove handlers on switch buttons and views $buttons
* remove handlers on breadcrumbs
* web: memory leak: correctly debind handlers
* im_odoo_support: memory leak: remove fileupload handler odoo_support
Note: part of this commit was actually authored by aab
Diffstat (limited to 'addons/web/static/src/js/control_panel.js')
| -rw-r--r-- | addons/web/static/src/js/control_panel.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/addons/web/static/src/js/control_panel.js b/addons/web/static/src/js/control_panel.js index 18a03d8d55c..dba2ea0bb2a 100644 --- a/addons/web/static/src/js/control_panel.js +++ b/addons/web/static/src/js/control_panel.js @@ -77,6 +77,10 @@ var ControlPanel = Widget.extend({ return this._super(); }, + destroy: function() { + this._clear_breadcrumbs_handlers(); + return this._super.apply(this, arguments); + }, /** * @return {Object} the Bus the ControlPanel is listening on */ @@ -109,7 +113,9 @@ var ControlPanel = Widget.extend({ // Render the breadcrumbs if (status.breadcrumbs) { - new_cp_content.$breadcrumbs = this._render_breadcrumbs(status.breadcrumbs); + this._clear_breadcrumbs_handlers(); + this.$breadcrumbs = this._render_breadcrumbs(status.breadcrumbs); + new_cp_content.$breadcrumbs = this.$breadcrumbs; } // Detach control_panel old content and attach new elements @@ -205,6 +211,17 @@ var ControlPanel = Widget.extend({ } }, /** + * Private function that removes event handlers attached on the currently + * displayed breadcrumbs. + */ + _clear_breadcrumbs_handlers: function () { + if (this.$breadcrumbs) { + _.each(this.$breadcrumbs, function ($bc) { + $bc.off(); + }); + } + }, + /** * Private function that updates the SearchView's visibility and extend the * breadcrumbs area if the SearchView is not visible * @param {openerp.web.SearchView} [searchview] the searchview Widget |
