https://bugs.kde.org/show_bug.cgi?id=528823
Bug ID: 528823
Summary: Repeated Global Theme switches don't notify kdeglobals
changes until the page is reopened
Classification: Applications
Product: systemsettings
Version First 6.8.2
Reported In:
Platform: Arch Linux
OS: Linux
Status: REPORTED
Severity: minor
Priority: NOR
Component: kcm_lookandfeel
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
SUMMARY
KLookAndFeelManager applies each theme value by:
1. updating the associated defaults (~/.config/kdedefaults/<file>)
2. reverting the user's config to the default (and notifying)
It uses KSharedConfig, and inside System Settings the KCM's LookAndFeelSettings
skeleton keeps 'kdeglobals' open while the Global Theme page is open. Only the
first theme switch causes notifications to be sent. Subsequent switches send no
notifications (due to short-circuiting inside KConfig), so listeners such as
kde-gtk-config will miss the change. Leaving the page destroys the KCM which
means returning will cause the next switch to work correctly.
I first noticed this when Emacs didn't follow light/dark switches, because
GSettings color-scheme kept the previous mode. Further testing showed that
after switching from an Oxygen global theme back to Breeze, KDE used the breeze
icon theme while GTK apps stayed on oxygen.
This doesn't affect one-shot processes because they parse the configs when
started.
STEPS TO REPRODUCE
1. Make sure "Switch to dark mode at night" is off so specific themes can be
applied.
2. Use the following command to print a timestamped line of when a kdeglobals
key is notified:
dbus-monitor --session
"type='signal',interface='org.kde.kconfig.notify',path='/kdeglobals'" \
| awk '/^signal/ { split($2, t, "="); ts = t[2] } /^ *string "/ { g = $2 }
/array of bytes "(ColorScheme|widgetStyle|Theme)"/ { s = g "/" $4;
gsub(/"/, "", s); print strftime("%T", ts), s; fflush() }'
3. In System Settings > Global Theme, switch between various themes (preferably
light and dark) a few
times without leaving the Global Theme page.
OBSERVED RESULT
The first switch prints 3 lines. Subsequent switches print nothing.
EXPECTED RESULT
3 lines every time a theme is switched.
CAUSE
When a theme is switched, KLookAndFeelManager writes each key's new default. It
then calls KConfigGroup::revertToDefault(), which marks the entry as reverted
(the bReverted flag). Syncing doesn't clear that flag; only writing the entry
again or calling KConfig::reparseConfiguration() does. On the next theme
switch, KEntryMap::revertEntry() (called from revertToDefault()) finds the
entry still marked as reverted and deliberately does nothing, returning early.
The new value only reaches disk through the separate default KConfig, which
doesn't use KSharedConfig. The shared config never re-reads the defaults, so it
also always returns the defaults it initially read.
KSharedConfig's documentation (https://api.kde.org/ksharedconfig.html#details)
makes it clear that calling reparseConfiguration() to keep configuration in
sync with external changes is up to the code holding the shared config.
KLookAndFeelManager is the one making the external change to the default, so it
knows when to do so.
FIX
Merge request to follow
In KLookAndFeelManager::writeNewDefaults(), immediately after the config group
is synced, reparse its configuration. This re-reads it from storage (no writes
since it was just synced) and updates its view of defaults.
Tested on 6.8.2, with the patch I saw the expected behavior when reproducing.
HISTORY
Introduced in 5.22 by
https://invent.kde.org/plasma/plasma-workspace/-/commit/0d0bca58cfd6dcdba6bb12f8f69d7b0f7d9e1b69
Probably one of the causes of bug 421745.
--
You are receiving this mail because:
You are watching all bug changes.