From ea0c6e17505212dc598dab63ea5a2ab552b60c55 Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Wed, 2 Oct 2024 06:26:57 -0600 Subject: [PATCH] applets/panelspacer: Fix unchecked access, port iterator to for(of) Usually, child is an instance of a Loader with a `property Item applet` where applet usually an instance of PlasmaQuick::AppletQuickItem (or rather its subclass PlasmoidItem to be precise). However, applet could also be an instance of a dndSpacer placeholder, which is just an Item. Fixes the following error when dragging a piece of text over a panel: file:///usr/local/kde/usr/share/plasma/plasmoids/org.kde.plasma.panelspacer/contents/ui/main.qml:69: TypeError: Cannot read property 'pluginName' of undefined --- package/contents/ui/main.qml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml index 9ea0316..7b9bd42 100644 --- a/package/contents/ui/main.qml +++ b/package/contents/ui/main.qml @@ -366,11 +366,12 @@ PlasmoidItem { let thisSpacerIndex = null; let sizeHints = [0]; // Children order is guaranteed to be the same as the visual order of items in the layout - for (var i in panelLayout.children) { - const child = panelLayout.children[i]; - if (!child.visible) continue; + for (const child of panelLayout.children) { + if (!child.visible) { + continue; + } - if (child.applet && child.applet.plasmoid.pluginName === 'luisbocanegra.panelspacer.extended' && child.applet.plasmoid.configuration.expanding) { + if (child.applet?.plasmoid?.pluginName === 'luisbocanegra.panelspacer.extended' && child.applet.plasmoid.configuration.expanding) { if (child.applet.plasmoid === Plasmoid) { thisSpacerIndex = expandingSpacers