summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2014-12-01 16:28:09 +0100
committerGéry Debongnie <ged@odoo.com>2014-12-02 10:19:09 +0100
commitbfcfc62fbfa5c75a64fbd96ac55041ce030f0db7 (patch)
tree53d207f45363693a64f0d9764530e912908fdff9
parent286d7f80bf6fe930c4eac33d6498642cc4a7a2cd (diff)
[FIX] fix reloading problem (crash) in web client
The previous viewmanager (before its refactoring in sept/oct 2014) was ignoring some promises in its do_load_state method. The refactoring actually fixed that, but of course, some other code was dependent on the broken implementation. This commit removes the use of promises in do_load_state, which is functionally equivalent to the previous code. As a result, it relies on some subtle timing of the creation and initialization of various views. It is somewhat fragile, but it is actually what the former code did, only in a more explicit way.
-rw-r--r--addons/web/static/src/js/views.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js
index 35c424ceb9f..e5bb93e90df 100644
--- a/addons/web/static/src/js/views.js
+++ b/addons/web/static/src/js/views.js
@@ -828,16 +828,15 @@ instance.web.ViewManager = instance.web.Widget.extend({
}
},
do_load_state: function(state, warm) {
- var self = this,
- def = this.active_view.created;
if (state.view_type && state.view_type !== this.active_view.type) {
- def = def.then(function() {
- return self.switch_mode(state.view_type, true);
- });
+ // warning: this code relies on the fact that switch_mode has an immediate side
+ // effect (setting the 'active_view' to its new value) AND an async effect (the
+ // view is created/loaded). So, the next statement (do_load_state) is executed
+ // on the new view, after it was initialized, but before it is fully loaded and
+ // in particular, before the do_show method is called.
+ this.switch_mode(state.view_type, true);
}
- def.done(function() {
- self.active_view.controller.do_load_state(state, warm);
- });
+ this.active_view.controller.do_load_state(state, warm);
},
on_debug_changed: function (evt) {
var self = this,