Created attachment 145896 [details]
The two examples found of this happening
Discover has a handy "Launch" button which should help a user get right to the application after install. Krita is a fascinating exception, instead getting launched around 20× over. KDE Connect is similar but less extreme, getting launched 5 times. (See the attached screenshot)
STEPS TO REPRODUCE
1. Open Discover
2. Install Krita or KDE Connect
3. Click the "Launch" option
The application gets launched a lot of times
The application gets launched once
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.3
- Testing this with KDE Connect will be much kinder to your computer. I recommend trying that if you want to check out the bug.
- This bug seems to be caused by Discover launching all desktop files associated with a program, not just the one you get in your application menu. I assume this from all the entries of the respective software in /usr/share/applications/.
I can reproduce this with any multi-instance app if I click the "Launch" button multiple times while the app is still launching. Is that what you're doing? I can't get it to happen if I only click on the Launch button only once.
No, this occurs specifically with applications like Krita and it only requires a single click. Sorry if that was unclear. Did you try Krita or KDE Connect specifically? I can provide a screen recording if that is helpful. :^)
Created attachment 145942 [details]
Screen recording of the thing
I hope this clarifies. I didn't leave the recording for long enough that all windows finally loaded, but it's enough to cause some crash (within Krita) and sets my computer to a cozy temperature. Note that this is a single click.
I cannot reproduce the issue with Krita, but I think I might be able to with KDE Connect. Three windows are opened when I click "Launch". However they are all different. I suspect what's happening here is that Discover is launching all launchables that correspond to the AppStream ID of the thing you clicked "Launch" for, and, it just happens that there are three for KDE Connect.
Not sure about Krita though. Can you attach a screen recording of the issue happening with KDE Connect so I can see if I experienced the same thing as you?
(In reply to Nate Graham from comment #4)
> I cannot reproduce the issue with Krita, but I think I might be able to with KDE Connect.
> Three windows are opened when I click "Launch". However they are all different.
Interesting that it doesn't work for you in Krita. Do you have it installed as a Flatpak? I'm on KDE Neon, so I got it through the official repos. Yes, the KDE Connect windows are all different for me as well. It's the same as if you open /usr/share/applications/ and click all desktop files that relate to the app.
> I suspect what's happening here is that Discover is launching all launchables that correspond
> to the AppStream ID of the thing you clicked "Launch" for, and, it just happens that there are
> three for KDE Connect.
This is what I suspect as well…
> Not sure about Krita though. Can you attach a screen recording of the issue happening with
> KDE Connect so I can see if I experienced the same thing as you?
Absolutely! Though, it's late here now so I'll get to it tomorrow. In the meantime I can confirm that you seem to have gotten the same result as me there.
Created attachment 145949 [details]
Recording of opening Connect through Discover
Here's how it looks when launching KDE Connect through Discover. I guess it's the same as what you described?
I also checked and found out that Flatpak versions do not suffer from this same issue. I guess they can create no more than one desktop file per application? Not checking this before was an oversight on my part, sorry. It's good to know this now. :^)
Yep, that's what I see too.
Git commit d3fa32a3008f5ace0a66f24f869ddb14f40a6c2e by Aleix Pol Gonzalez, on behalf of Aleix Pol.
Committed on 18/03/2022 at 00:44.
Pushed by apol into branch 'master'.
pk: Use appstream information to launch an app
We no longer need to do weird package introspection to find the
M +9 -46 libdiscover/backends/PackageKitBackend/AppPackageKitResource.cpp