[pve-devel] [PATCH manager v2 1/2] ext6migrate: fix store load race condition
Dominik Csapak
d.csapak at proxmox.com
Mon Mar 14 13:41:22 CET 2016
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 <d.csapak at proxmox.com>
---
changes from v1:
* instead of checking manually if the component is gone
we make a managed listener
* also do this for some other cases, where we previously
did not do any cleanup or check
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 ba9f774..76c4d67 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 d2c1783..d7b0dc9 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 8902c86..7979dd6 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -207,7 +207,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 10d8e44..9aafc7c 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 9ed1213..825d7a2 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 0e21767..815e0c4 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 96e7ce2..06738ab 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') {
--
2.1.4
More information about the pve-devel
mailing list