Bug 439159 - "Add widgets..." and "Show alternatives..." options from context menu stop working after manually restarting plasmashell process using `plasmashell --replace`
Summary: "Add widgets..." and "Show alternatives..." options from context menu stop wo...
Alias: None
Product: plasmashell
Classification: Unclassified
Component: general (show other bugs)
Version: 5.23.0
Platform: Archlinux Packages Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
: 443647 445438 445796 456556 (view as bug list)
Depends on:
Reported: 2021-06-25 16:14 UTC by Patrick Silva
Modified: 2022-07-30 18:48 UTC (History)
14 users (show)

See Also:
Latest Commit:
Version Fixed In:


Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Silva 2021-06-25 16:14:26 UTC
1. run "plasmashell --replace" with krunner
2. right-click on Plasma panel
3. choose "Add widgets..." or "Show alternatives..."

nothing happens

the option chosen in the last step works

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.22.80
KDE Frameworks Version: 5.84.0
Qt Version: 5.15.3
Graphics Platform: X11
Comment 1 Nate Graham 2021-07-29 15:54:29 UTC
Can reproduce.
Comment 2 Alexander Potashev 2021-09-03 14:59:39 UTC
Same here on Plasma 5.21.5, KF 5.83.0, Qt 5.15.2, X11.
Comment 3 Nate Graham 2021-09-29 18:09:56 UTC
Basically the first time Plasma crashes or is manually restarted during development activities, these functions break.

I've done some debugging and it appears that the problem is ShellCorona::handleContainmentAdded() not being run after plasmashell is restarted. This function is solely responsible for handling the signals that open those popups and handle the initial plasmoid setup script (if present), so when it doesn't get run, the connections don't get made and that functionality breaks.
Comment 4 Nate Graham 2021-09-29 18:41:01 UTC
It appears that configDialog.containmentPlugin isn't set by the time the panel configuration window appears...

Getting towards the end of my ability to debug this, I fear.
Comment 5 Nate Graham 2021-09-29 18:49:47 UTC
Actually the same bug happens when you try to trigger the Widget Explorer from the context menu, so I guess it isn't getting set in multiple places, or else maybe the need for it to be set is unnecessary?
Comment 6 Nate Graham 2021-09-29 19:29:12 UTC
Urgh the complexity of this code makes me want to cry
Comment 7 Nate Graham 2021-09-29 19:49:06 UTC
Breakthrough thanks to rubber ducking with my son: restarting with plasmashell --replace causes this bug, but manually killing plasmashell and launching it manually with either `plasmashell` or `kstart5 plasmashell` avoids the bug. So there is something about plasmashell's --replace argument that triggers it...
Comment 8 Nate Graham 2021-09-29 19:52:47 UTC
It appears that this connection in shellcorona.cpp:

connect(this, &ShellCorona::containmentAdded, this, &ShellCorona::handleContainmentAdded);

happens too late when using plasmashell --restart. In this case, the containmentAdded() signal in corona.cpp is emitted, but it doesn't do anything because the connection hasn't been made yet. When launching plasmashell but it's not already running, the signal gets emitted after the connection has been made, so it always works.
Comment 9 Nate Graham 2021-09-29 22:35:30 UTC
The only difference seems to be this line in shell/main.cpp:

KDBusService service(KDBusService::Unique | KDBusService::StartupOption(replace ? KDBusService::Replace : 0));
Comment 10 Nate Graham 2021-09-29 22:41:29 UTC
Hmm maybe the problem is in KDbusAddons? This doesn't look right...

if (options & KDBusService::Replace) {
} else if (options & KDBusService::Unique) {

If I'm reading this right, when both KDBusService::Replace and KDBusService::Unique are specified, it seems like the code to handle KDBusService::Unique gets ignored.
Comment 11 Nate Graham 2021-09-29 23:41:04 UTC
Hmm, changing that doesn't seem to fix the problem...
Comment 12 Nate Graham 2021-09-30 00:25:10 UTC
Giving up for now since this only affects developer/power user setups and has a trivial workaround (`killall plasmashell && kstart5 plasmashell`)
Comment 13 David Edmundson 2021-10-04 16:08:09 UTC
You found all the parts.

Cold case:
 - we call ShellCorona::load from startup
 - we have no kactivities loaded yet, we do an early return and connect
 - we call ShellCorona::init
 - activities load, we start the real load via the connect

Restart case:
 - we call ShellCorona::load
 - we have no kactivities loaded yet, we do an early return and connect
 - We start an event loop, waiting for our bus name to appear
 - activities load, we start the real load
 - we call ShellCorona::init

>Urgh the complexity of this code makes me want to cry

Was also a valid analysis.
Comment 14 Patrick Silva 2021-10-13 02:35:09 UTC
*** Bug 443647 has been marked as a duplicate of this bug. ***
Comment 15 Patrick Silva 2021-11-14 01:28:22 UTC
*** Bug 445438 has been marked as a duplicate of this bug. ***
Comment 16 Patrick Silva 2021-11-20 16:22:50 UTC
*** Bug 445796 has been marked as a duplicate of this bug. ***
Comment 17 Waqar Ahmed 2022-01-19 06:43:48 UTC
I ran into this problem today but with the difference that "Show Alternatives.." is working for me but "Add Widgets" doesn't. Also, I am running plasma like normal, didn't restart it manually or anything so I think this is a non poweruser / developer bug.

Plasma version 5.23.4
Frameworks: 5.89
Comment 18 Nate Graham 2022-02-22 19:43:41 UTC
Raising priority as it seems to be affecting users after Plasma crashes, not just developers.
Comment 19 Fushan Wen 2022-06-15 01:36:02 UTC
Not a regression in 5.25.
Comment 20 Nate Graham 2022-07-13 19:16:45 UTC
*** Bug 456556 has been marked as a duplicate of this bug. ***