Skip to content
Commit af1cc78d authored by Rocket Aaron's avatar Rocket Aaron Committed by Fushan Wen
Browse files

Avoid creating gtkrc-2.0 if it does not exist

This MR would fix the following 2 bugs: Plasma does not follow `GTK2_RC_FILES` environment variable and would create `~/.gtkrc-2.0` every time on login.

---

Here is the more detailed explanation:

`gmenu-dbusmenu-proxy` hardcoded `gtkrcPath` as `QDir::homePath() + QLatin1String("/.gtkrc-2.0")`:

https://invent.kde.org/plasma/plasma-workspace/-/blob/v5.27.1/gmenu-dbusmenu-proxy/menuproxy.cpp#L163

but it's not creating the file if it's not present. `kde-gtk-config`'s `Gtk2ConfigEditor::removeLegacyStrings()` is the cause:

https://invent.kde.org/plasma/kde-gtk-config/-/blob/v5.27.1/kded/config_editor/gtk2.cpp#L54

it uses `Utils::readFileContents(QFile &file)`

https://invent.kde.org/plasma/kde-gtk-config/-/blob/v5.27.1/kded/config_editor/utils.cpp#L19

which calls `file.open(QIODevice::ReadWrite | QIODevice::Text)`, and the mode `ReadWrite` means to create the file if it's not exist:

https://doc.qt.io/qt-5/qfile.html#open

So at startup, `kde-gtk-config` launches and a empty `~/.gtkrc-2.0` file is created, then `gmenu-dbusmenu-proxy` watchs the file creation

https://invent.kde.org/plasma/plasma-workspace/-/blob/v5.27.1/gmenu-dbusmenu-proxy/menuproxy.cpp#L106

and write the content to the file.

Furthermore, even if `~/.gtkrc-2.0` does not exist, `Gtk2ConfigEditor::removeLegacyStrings()` would still write "modified" content to the file

https://invent.kde.org/plasma/kde-gtk-config/-/blob/v5.27.1/kded/config_editor/gtk2.cpp#L76

but in that case, it would just create an empty file, for `gmenu-dbusmenu-proxy` to watch and write something to it.

BUG: 415770
BUG: 417534
FIXED-IN: 5.27.2
parent 124a0105
Loading
Loading
Loading
Pipeline #340040 passed with stage
in 54 seconds
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment