From 6bc75b61be1f8cd5c4e459bb5f8f2da7fa8ca29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 3 Apr 2017 13:54:28 +0200 Subject: [FIX] web: better error handling in view and action manager Before this commit, it could happen that a crash at the wrong time (for example, while loading a view) cause the web client to crash for various reasons. For example, it assumes that the active view always has a valid controller. Or the action manager could not detach the previous view, so we had the 'double view' rendering in the web client. With this commit, we add some protections at various points. Those safety measures should help the user keep working even if a specific view did crash. --- addons/web/static/src/js/chrome/view_manager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/chrome/view_manager.js') diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js index 02250d5cc15..d8f0e3776d9 100644 --- a/addons/web/static/src/js/chrome/view_manager.js +++ b/addons/web/static/src/js/chrome/view_manager.js @@ -59,7 +59,8 @@ var ViewManager = Widget.extend(ControlPanelMixin, { */ on_detach_callback: function() { this.is_in_DOM = false; - if (this.active_view && this.active_view.controller.on_detach_callback) { + var controller = this.active_view && this.active_view.controller; + if (controller && controller.on_detach_callback) { this.active_view.controller.on_detach_callback(); } }, @@ -282,7 +283,7 @@ var ViewManager = Widget.extend(ControlPanelMixin, { view.$fragment = view.$fragment.contents(); view.loaded.resolve(); }); - }); + }).fail(view.loaded.reject.bind(view.loaded)); } else { view.loaded = view.loaded.then(function() { view_options = _.extend({}, view_options, self.env); -- cgit v1.2.3