[pbs-devel] [PATCH proxmox-backup 1/2] ui: NavigationTree: do not modify list while iterating

Dominik Csapak d.csapak at proxmox.com
Wed Mar 10 10:10:46 CET 2021


iterating over a nodeinterfaces children while removing them
will lead to 'child' being undefined

instead collect the children to remove in a separate list
and iterate over them

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/NavigationTree.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/www/NavigationTree.js b/www/NavigationTree.js
index a9e97567..4bdfbc66 100644
--- a/www/NavigationTree.js
+++ b/www/NavigationTree.js
@@ -188,11 +188,13 @@ Ext.define('PBS.view.main.NavigationTree', {
 		}
 	    }
 
+	    let toremove = [];
 	    list.eachChild((child) => {
 		if (!newSet[child.data.path]) {
-		    list.removeChild(child, true);
+		    toremove.push(child);
 		}
 	    });
+	    toremove.forEach((child) => list.removeChild(child, true));
 
 	    if (view.pathToSelect !== undefined) {
 		let path = view.pathToSelect;
-- 
2.20.1






More information about the pbs-devel mailing list