Skip to content

Commit

Permalink
applets/panelspacer: Fix unchecked access, port iterator to for(of)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ratijas authored and luisbocanegra committed Oct 2, 2024
1 parent 46a12d9 commit ea0c6e1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea0c6e1

Please sign in to comment.