public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 5/5] ui: tape/ChangerStatus: handle vanishing view during reload
Date: Mon,  1 Mar 2021 12:22:43 +0100	[thread overview]
Message-ID: <20210301112243.15842-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210301112243.15842-1-d.csapak@proxmox.com>

since reload is an async function, the view can be destroyed during
any 'await' point. Subsequent accesses to the view will fail, and we
will land in the catch. Check there if the view is destroyed, and
do not raise an error with the user then

also cancel any outstanding timer on 'deactivate' and 'destroy'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/tape/ChangerStatus.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/www/tape/ChangerStatus.js b/www/tape/ChangerStatus.js
index dab34038..04422936 100644
--- a/www/tape/ChangerStatus.js
+++ b/www/tape/ChangerStatus.js
@@ -285,12 +285,17 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    }
 	},
 
-	reload: function() {
+	cancelReload: function() {
 	    let me = this;
 	    if (me.reloadTimeout !== undefined) {
 		clearTimeout(me.reloadTimeout);
 		me.reloadTimeout = undefined;
 	    }
+	},
+
+	reload: function() {
+	    let me = this;
+	    me.cancelReload();
 	    me.reload_full(true);
 	},
 
@@ -398,6 +403,10 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 		}
 		Proxmox.Utils.setErrorMask(me.lookup('content'));
 	    } catch (err) {
+		if (!view || view.isDestroyed) {
+		    return;
+		}
+
 		if (!use_cache) {
 		    Proxmox.Utils.setErrorMask(view);
 		}
@@ -470,11 +479,13 @@ Ext.define('PBS.TapeManagement.ChangerStatus', {
 	    }
 
 	    view.title = `${gettext("Changer")}: ${view.changer}`;
+	    me.reload();
 	},
     },
 
     listeners: {
-	activate: 'reload',
+	deactivate: 'cancelReload',
+	destroy: 'cancelReload',
     },
 
     tbar: [
-- 
2.20.1





  parent reply	other threads:[~2021-03-01 11:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-01 11:22 [pbs-devel] [PATCH proxmox-backup 1/5] ui: tape: add DriveStatus panel Dominik Csapak
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 2/5] ui: MainView: adapt router to add changer/drive entries Dominik Csapak
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 3/5] ui: NavigationTree: add entries for changers/drives Dominik Csapak
2021-03-01 11:22 ` [pbs-devel] [PATCH proxmox-backup 4/5] ui: tape: ChangerStatus: remove changerselector combobox Dominik Csapak
2021-03-01 11:22 ` Dominik Csapak [this message]
2021-03-01 11:39 ` [pbs-devel] applied: [PATCH proxmox-backup 1/5] ui: tape: add DriveStatus panel Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210301112243.15842-5-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal