https://bugs.kde.org/show_bug.cgi?id=366146

--- Comment #8 from muzuiget <muzui...@gmail.com> ---
Oh, I am using dual monitors, this bug annoy me almost a year, finally I found
out what cause this problem, and know which keyword to search then go into this
issue.

The reason is "You can't add second system tray after plamsashell started".

After you click "Add Panel -> Default Panel" to add second panel, plamsashell
will eat all your memory in a few seconds, then your desktop nearly freezing.

Test on Fedora 24, with package "plasma-desktop.x86_64", version 5.7.5-1.fc24.

After so many times to run "sleep 15 && killall -s KILL plasmashell" then
testing. I found out the reason which I said above;

When you click the menuitem, plasmashell will execute the file
/usr/share/plasma/layout-templates/org.kde.plasma.desktop.defaultPanel/contents/layout.js,
after comment out the line

    panel.addWidget('org.kde.plasma.systemtray');

The new panel added normally without the system tray;

Then I do more digging, and found out a file
/usr/share/plasma/plasmoids/org.kde.plasma.systemtray/contents/ui/main.qml 

    Item {
        id: root

        Layout.minimumWidth: internalSystray.Layout.minimumWidth
        Layout.minimumHeight: internalSystray.Layout.minimumHeight

        Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
        property Item internalSystray

        Component.onCompleted: {
            root.internalSystray = plasmoid.nativeInterface.internalSystray;

            if (root.internalSystray == null) {
                return;
            }
            root.internalSystray.parent = root;
            root.internalSystray.anchors.fill = root;
        }

        Connections {
            target: plasmoid.nativeInterface
            onInternalSystrayChanged: {
                root.internalSystray =
plasmoid.nativeInterface.internalSystray;
                root.internalSystray.parent = root;
                root.internalSystray.anchors.fill = root;
            }
        }
    }

I am not know qml programming, but I guess "org.kde.plasma.private.systemtray"
is really system tray widget and it's a singltion, and
"org.kde.plasma.systemtray" just a "proxy/container type" widget, the latter
share the same former instance.  When add second system tray, that will be two
"org.kde.plasma.private.systemtray" instance. It look like there are a
recursive call between `onCompleted` and `onInternalSystrayChanged`. After
delete the two methods body, The new panel added normally without the system
tray too.

As I said I don't kown qml, So, I don't konw how to fix it. 

Luckily I konw JavaScript, after reading

https://userbase.kde.org/KDE_System_Administration/PlasmaDesktopScripting#Update_scripts

Here is my workaround, to edit the layout.js, avoid to add system tray in new
panel.

replace the line

    panel.addWidget('org.kde.plasma.systemtray');

to 

    (function() {
        for (var i = 0; i < panelIds.length; i++) {
            var tmpPanel = panelById(panelIds[i]);
            if (tmpPanel.id === panel.id) {
                continue;
            }
            var trays = tmpPanel.widgets('org.kde.plasma.systemtray');
            if (trays.length > 0) {
                return;
            }
        }
        panel.addWidget('org.kde.plasma.systemtray');
    })();

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to