[FIX] properly destroy client widgets (web client)
authorGéry Debongnie <ged@odoo.com>
Thu, 23 Oct 2014 07:12:51 +0000 (09:12 +0200)
committerGéry Debongnie <ged@odoo.com>
Wed, 29 Oct 2014 07:38:17 +0000 (08:38 +0100)
The new action manager only destroyed viewmanager widgets instead of
any old widget.  It now checks for the widget class.

Also, minor improvement to clear_widgets: vms used to stand for
view_managers, but it can destroy any widget.

addons/web/static/src/js/views.js

index 48a61e8..12049d5 100644 (file)
@@ -44,7 +44,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
             var to_destroy = this.widgets;
             this.widgets = [];
         }
-        if (widget instanceof instance.web.ViewManager) {
+        if (widget instanceof instance.web.Widget) {
             this.widgets.push(widget);
         } else {
             this.widgets.push({
@@ -103,11 +103,9 @@ instance.web.ActionManager = instance.web.Widget.extend({
             });
         }
     },
-    clear_widgets: function(vms) {
-        _.each(vms || this.widgets, function (vm) {
-            vm.destroy();
-        });
-        if (!vms) {
+    clear_widgets: function(widgets) {
+        _.invoke(widgets || this.widgets, 'destroy');
+        if (!widgets) {
             this.widgets = [];
             this.inner_widget = null;
         }