From 7e98e32959231b68985b444afbcde06bf64a5fb7 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 9 May 2017 14:08:47 +0200 Subject: [PATCH] [FIX] web: traceback when quickly clicking on back button Before this rev., there might be a crash when the user quickly clicked several times on the browser's back button. This crash occurred in the code saving/restoring the scroll position of the current action. When clicking fast on the back button, several actions are executed but don't wait for each other (those actions are triggered by the hashchange event), so when it is fast, and mainly when the appswitcher is involved, it may happen that we try to get the scroll position of an action that isn't loaded yet. opw~741814 --- addons/web/static/src/js/action_manager.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/action_manager.js b/addons/web/static/src/js/action_manager.js index 7e8b89dda68..974bfb982d7 100644 --- a/addons/web/static/src/js/action_manager.js +++ b/addons/web/static/src/js/action_manager.js @@ -175,13 +175,18 @@ var ViewManagerAction = WidgetAction.extend({ * @param {int} [scrollTop] the number of pixels to scroll */ set_scrollTop: function(scrollTop) { - this.widget.active_view.controller.set_scrollTop(scrollTop); + if (this.widget.active_view && this.widget.active_view.controller) { + this.widget.active_view.controller.set_scrollTop(scrollTop); + } }, /** * @return {int} the number of pixels the webclient is scrolled when leaving the action */ get_scrollTop: function() { - return this.widget.active_view.controller.get_scrollTop(); + if (this.widget.active_view && this.widget.active_view.controller) { + return this.widget.active_view.controller.get_scrollTop(); + } + return this._super.apply(this, arguments); }, /** * @return {Array} array of Objects that will be interpreted to display the breadcrumbs