[pve-devel] [PATCH manager] fix #944: fix race condition in nodeselector

Dominik Csapak d.csapak at proxmox.com
Mon Apr 25 14:58:12 CEST 2016


in commit
bff3359e1d83436614bb3773f8983997275df8dd

we set the default value of the nodeselector to [] (empty array),
because in the storage edit windows, this is the value
that the field gets after a store load. (to prevent dirtychange)

unfortunately, in the backup edit window, there is a race condition.
there, the store load sets the value to null (not []) and we filter for
!node || ...

sometimes, we filter before the store sets the value to null
(and thus it is still [])

in javascript !null === true, but ![] === false, so we filter out
all the vms if we have a value of []

now, instead of setting [] as the default value, we leave it
and call resetOriginalValue after the store loaded to prevent
the initial issue of isDirty

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/form/NodeSelector.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/www/manager6/form/NodeSelector.js b/www/manager6/form/NodeSelector.js
index 8c69430..baf5b0b 100644
--- a/www/manager6/form/NodeSelector.js
+++ b/www/manager6/form/NodeSelector.js
@@ -9,10 +9,6 @@ Ext.define('PVE.form.NodeSelector', {
 
     // only allow those nodes (array)
     allowedNodes: undefined,
-    // set default value to empty array, else it inits it with
-    // null and after the store load it is an empty array,
-    // triggering dirtychange
-    value: [],
     valueField: 'node',
     displayField: 'node',
     store: {
@@ -96,6 +92,13 @@ Ext.define('PVE.form.NodeSelector', {
         }
 
         me.callParent();
-        me.getStore().load();
+        me.getStore().load({
+	    scope: this,
+	    callback: function(records, operation, success) {
+		if (success === true) {
+		    this.resetOriginalValue();
+		}
+	    }
+	});
     }
 });
-- 
2.1.4





More information about the pve-devel mailing list