Bug 447903 - New regional format in 5.24 generates incorrect plasma-localerc
Summary: New regional format in 5.24 generates incorrect plasma-localerc
Status: RESOLVED FIXED
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_formats (show other bugs)
Version: master
Platform: openSUSE Linux
: VHI normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2022-01-03 23:02 UTC by Thiago Sueto
Modified: 2022-01-10 17:42 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thiago Sueto 2022-01-03 23:02:05 UTC
SUMMARY
I believe this is a major breaking bug which is common but not that discoverable and that ought not to end up in the final release of 5.24.

With Plasma 5.23, plasma-localerc is correctly generated via the System Settings KCM:

[Formats]
LANG=pt_BR.UTF-8

With Plasma from git (5.24), it is generated without the .UTF-8 bit:

[Formats]
LANG=pt_BR

Which causes a few issues:

* It's impossible to type accents, however รง works

* On X11, the following error shows up on the terminal whenever you type an accent key in a Qt application:

qt.xkb.compose: failed to create compose table

* On Wayland, the following error shows up on the terminal under the same conditions, where the first line is repeated around 10 times:

xkbcommon: ERROR: /usr/share/X11/locale/iso8859-1/Compose:49:29: string literal is not a valid UTF-8 string
xkbcommon: ERROR: /usr/share/X11/locale/iso8859-1/Compose:49:29: too many errors
xkbcommon: ERROR: /usr/share/X11/locale/iso8859-1/Compose:49:29: failed to parse file
qt.qpa.input.methods: failed to create compose table

This does not occur on non-Qt applications (tigervnc, Firefox).

I managed to reproduce this issue 100% because I can trivially switch between openSUSE Krypton and Tumbleweed. After downgrading to Tumbleweed (with Plasma 5.23), deleting the plasma-localerc, using the Formats KCM to set the format to Brazil, and then rebooting, the issue is resolved; after upgrading to Krypton (with Plasma from git / 5.24), deleting the plasma-localerc, using the Formats KCM to set the format to Brazil, and then rebooting, the issue is reproduced.

That is to say: it's hard to discover this bug because the config file needs to be updated with the new settings, so a user upgrading from 5.23 would likely not notice it, yet a new user will.

STEPS TO REPRODUCE

Small note: I haven't yet tested with other distros, but given how easy this one is to reproduce...

1. Get a distro or live image or build with Plasma from git
2. Delete the file ~/.config/plasma-localerc
3. Go to the Formats section of the Regional Formats KCM
4. Set it to Brazil format
5. Look at the new ~/.config/plasma-localerc

OBSERVED RESULT
The file contains:
[Formats]
LANG=pt_BR

EXPECTED RESULT
The file should contain:
[Formats]
LANG=pt_BR.UTF-8
Comment 1 Thiago Sueto 2022-01-03 23:33:33 UTC
Forgot to mention: to reproduce this, the file should be generated after the update has been applied, of course. So after a logout/login.
Comment 2 David Edmundson 2022-01-06 16:27:51 UTC
Old code that got lost:

    QString cvalue = locale.name();
    if (!cvalue.contains(QLatin1Char('.')) && cvalue != QLatin1Char('C')) {
        // explicitly add the encoding,
        // otherwise Qt doesn't accept dead keys and garbles the output as well
        cvalue.append(QLatin1Char('.') + QTextCodec::codecForLocale()->name());
    }
Comment 3 Bug Janitor Service 2022-01-09 22:03:25 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/1342
Comment 4 Nate Graham 2022-01-10 17:36:08 UTC
Git commit 083ef23af2d0577e21a4a18654616500fca593f5 by Nate Graham, on behalf of David Edmundson.
Committed on 10/01/2022 at 17:26.
Pushed by ngraham into branch 'master'.

[kcms/formats] Write text codec into localerc files

In the port this snippet got lost. Without the suffix we lose information needed by clients.

This patch will also affect the names presented as a subtitle in the list.
If that is undesired we can introduce a new role.

M  +7    -1    kcms/formats/localelistmodel.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/083ef23af2d0577e21a4a18654616500fca593f5