diff options
| author | Aaron Bohy <aab@odoo.com> | 2018-08-30 15:00:02 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2018-09-05 08:47:21 +0200 |
| commit | db9b91ffe684dbc2c7504680daed3238b2c875a4 (patch) | |
| tree | 6930abd56da339f6ff84944d959393ebd449381d /addons/web/static/src/js/views/basic/basic_controller.js | |
| parent | 027436ee5aef3ff4d94d10ed69e51659e81f2267 (diff) | |
[FIX] web: BasicController: remove deadlock situation
This rev. removes a deadlock situation that could *theoretically*
occur, but that was actually hard to reach in practice.
Before saving a record (e.g. in a form view), all field widgets
are asked to commit their value (in case they wouldn't have
notified the model yet, e.g. because the user just changed them).
For instance, let's assume that the user fills an input field, and
then triggers the save. In practice, by triggering the save, it
will force the widget to notify the model of its new value (because
it looses the focus). This is also the case using keyboard
navigation, as it actually simulates clicks. So when the widget is
asked to commit its value right after, it has nothing more to
commit.
This is fortunate, because if it actually had something to commit,
we would end up in a deadlock ('commitChanges' is executed in a
mutex, and if the widget triggers a new value, '_applyChange' is
called, and is executed in that mutex as well). In fact, executing
'commitChanges' in a mutex is useless, as '_applyChange', which is
called when a widget has something to commit, is already executed
in the mutex.
So this rev. removes the use of the mutex in 'commitChanges'.
Doing so broke several Many2One tests, because they wrongly relied
on the presence of the mutex for scenarios where the user quick
creates a relational record, and then directly saves (before the
relational record is actually created). We thus handled that
usecase properly to make the tests pass.
Task 1878254.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_controller.js | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 5767969d15c..767a6511ce3 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -180,11 +180,9 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { // mutex-protected as commitChanges function of x2m has to be aware of // all final changes made to a row. var self = this; - return this.mutex - .exec(this.renderer.commitChanges.bind(this.renderer, recordID || this.handle)) - .then(function () { - return self.mutex.exec(self._saveRecord.bind(self, recordID, options)); - }); + return this.renderer.commitChanges(recordID || this.handle).then(function () { + return self.mutex.exec(self._saveRecord.bind(self, recordID, options)); + }); }, /** * @override |
