From f2a6ce6cf107c791de1e127bfe0055dbd20c9aaa Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 14 Mar 2016 13:41:22 +0100 Subject: [PATCH] ext6migrate: fix store load race condition when we click on a node/container/vm and quickly click on something else, there might be a race condition, where the store finished loading and we try to change dom elements, which are not there anymore so we change the store.on to me.mon, which deletes the handler when the component is gone in the logview panel we use API2Request, where we cannot do this, so we check if the component is destroyed manually also we change this whenever we change a dom element in a callback Signed-off-by: Dominik Csapak --- www/manager6/dc/Summary.js | 2 +- www/manager6/form/ComboGrid.js | 4 ++-- www/manager6/lxc/Config.js | 2 +- www/manager6/node/Config.js | 2 +- www/manager6/panel/LogView.js | 4 ++++ www/manager6/qemu/Config.js | 2 +- www/manager6/storage/ContentView.js | 5 +---- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/www/manager6/dc/Summary.js b/www/manager6/dc/Summary.js index ba9f7742..76c4d67d 100644 --- a/www/manager6/dc/Summary.js +++ b/www/manager6/dc/Summary.js @@ -76,7 +76,7 @@ Ext.define('PVE.dc.NodeView', { me.callParent(); - rstore.on('load', function(s, records, success) { + me.mon(rstore,'load', function(s, records, success) { if (!success) { return; } diff --git a/www/manager6/form/ComboGrid.js b/www/manager6/form/ComboGrid.js index d2c1783f..d7b0dc95 100644 --- a/www/manager6/form/ComboGrid.js +++ b/www/manager6/form/ComboGrid.js @@ -240,7 +240,7 @@ Ext.define('PVE.form.ComboGrid', { me.createPicker(); } - me.store.on('beforeload', function() { + me.mon(me.store, 'beforeload', function() { if (!me.isDisabled()) { me.setDisabled(true); me.enableAfterLoad = true; @@ -248,7 +248,7 @@ Ext.define('PVE.form.ComboGrid', { }); // hack: autoSelect does not work - me.store.on('load', function(store, r, success, o) { + me.mon(me.store, 'load', function(store, r, success, o) { if (success) { me.clearInvalid(); diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js index 491a5f88..8244298e 100644 --- a/www/manager6/lxc/Config.js +++ b/www/manager6/lxc/Config.js @@ -205,7 +205,7 @@ Ext.define('PVE.lxc.Config', { me.callParent(); - me.statusStore.on('load', function(s, records, success) { + me.mon(me.statusStore,'load', function(s, records, success) { var status; if (!success) { me.workspace.checkVmMigration(me.pveSelNode); diff --git a/www/manager6/node/Config.js b/www/manager6/node/Config.js index 10d8e442..9aafc7c8 100644 --- a/www/manager6/node/Config.js +++ b/www/manager6/node/Config.js @@ -217,7 +217,7 @@ Ext.define('PVE.node.Config', { me.callParent(); - me.statusStore.on('load', function(s, records, success) { + me.mon(me.statusStore,'load', function(s, records, success) { var uptimerec = s.data.get('uptime'); var powermgmt = uptimerec ? uptimerec.data.value : false; if (!caps.nodes['Sys.PowerMgmt']) { diff --git a/www/manager6/panel/LogView.js b/www/manager6/panel/LogView.js index 9ed12132..825d7a27 100644 --- a/www/manager6/panel/LogView.js +++ b/www/manager6/panel/LogView.js @@ -41,6 +41,10 @@ Ext.define('PVE.panel.LogView', { var me = this; var el = me.dataCmp.el; + if (me.destroyed) { // return if element is not there anymore + return; + } + if (me.viewInfo && me.viewInfo.start === start && me.viewInfo.end === end && me.viewInfo.total === total && me.viewInfo.textLength === text.length) { diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js index 0e217672..815e0c4c 100644 --- a/www/manager6/qemu/Config.js +++ b/www/manager6/qemu/Config.js @@ -218,7 +218,7 @@ Ext.define('PVE.qemu.Config', { */ me.callParent(); - me.statusStore.on('load', function(s, records, success) { + me.mon(me.statusStore,'load', function(s, records, success) { var status; var qmpstatus; var spice = false; diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js index 96e7ce2b..06738ab0 100644 --- a/www/manager6/storage/ContentView.js +++ b/www/manager6/storage/ContentView.js @@ -511,10 +511,7 @@ Ext.define('PVE.storage.ContentView', { // disable the buttons/restrict the upload window // if templates or uploads are not allowed - me.statusStore.on('load', function(s,records,succes) { - if (me.destroyed) { // if the element is not there anymore, do nothing - return; - } + me.mon(me.statusStore,'load', function(s,records,succes) { var availcontent = []; Ext.Array.each(records, function(item){ if (item.id === 'content') {