]> git.proxmox.com Git - pve-manager.git/commitdiff
ui snapshot tree: avoid exception in delayd load when view is gone
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 30 Jan 2020 18:43:16 +0000 (19:43 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 30 Jan 2020 18:43:20 +0000 (19:43 +0100)
If one switched through guest fast (e.g., keeping the down-arrow key
pressed) while staying on the snapshot panel, it could happen that
the previous view got already destroyed once the success callback of
the feature API request got executed.

Then the ExtJS ViewModels' set method got a "null" back from its
me.getStub(...) call, and tried to access members of that, resulting
in a TypeError exception.

Avoid that by checking if we're already destroyed or still around
before doing that call. During the time we are already in the
callback we shouldn't be able to get destroyed in parallel due to JS
single thread nature and no yield point here, so this is safe.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/manager6/tree/SnapshotTree.js

index 4f8340184956723abb5409431f5c460c03ae9df1..e365a16eebf5e012831b77729089046fbdcdf2a2 100644 (file)
@@ -164,6 +164,11 @@ Ext.define('PVE.guest.SnapshotTree', {
                params: { feature: 'snapshot' },
                method: 'GET',
                success: function(response, options) {
+                   if (me.destroyed) {
+                       // this is in a delayed task, the current view could been
+                       // destroyed already; then we mustn't do viemodel set
+                       return;
+                   }
                    let res = response.result.data;
                    vm.set('snapshotFeature', !!res.hasFeature);
                }