Created attachment 147067 [details]
Error when trying to change Discord's desktop entry
If user tries to edit a desktop entry in /usr/share/applications that is a symlink to some file without write access, this results in an error.
STEPS TO REPRODUCE
1. Install a package that contains a symlink from /usr/share/applications. For example, Discord package on Arch/Manjaro: `pacman -S discord`
2. Open Application Launcher
3. Right-click on an app installed on step 1, select 'Edit application'
4. Change something and click 'Save'
Could not save properties due to insufficient write access to:
~/.local/share/applications/discord.desktop is a symlink to /opt/discord/discord.desktop.
~/.local/share/applications/discord.desktop is successfully saved and is an arbitrary file owned by the current user.
Linux distro: Manjaro stable
KDE Plasma Version: 5.23.5, master
KDE Frameworks Version: 5.90.0, master
Qt Version: 5.15.2
Similar bug: https://bugs.kde.org/show_bug.cgi?id=394476
But it needs to be resolved separately IMO, since it involves editing a file that's already in `~/.local/share/applications/` but is unwriteable for the current user.
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/768
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/848
Git commit a4be43231840a145c808f6ce81217f02f03935e8 by Ahmad Samir.
Committed on 13/06/2022 at 19:19.
Pushed by ahmadsamir into branch 'master'.
KPropertiesDialog: fix saving changes when editing a .desktop file symlink
Consider the use case of:
/usr/share/applications/foo.desktop is symlink to /opt/someapp/foo.desktop
relativeAppsLocation() was using QFile::canonicalFilePath(), which meant
that foo.desktop would resolve to a file outside /usr/share/applications,
since the code, rightly, expects files in QStandardPaths::ApplicationsLocation
locations, m_sRelativePath would end up being empty, which makes the check in
KFilePropsPlugin::slotCopyFinished() fail, and the .desktop file wouldn't
get copied to ~/.local/share/applications/, and the saving would fail.
M +5 -3 src/widgets/kpropertiesdialog.cpp