https://bugs.kde.org/show_bug.cgi?id=526818
Bug ID: 526818
Summary: Locale-specifiers of existing config values are
changed when writing config
Classification: Frameworks and Libraries
Product: frameworks-kconfig
Version First unspecified
Reported In:
Platform: Other
OS: Linux
Status: REPORTED
Severity: normal
Priority: NOR
Component: general
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
Locale-specifiers without country code (e.g. [ca]) of existing config values
are changed to locale-specifiers with country code (e.g. [ca_ES]) when the
config file is written (e.g. because some completely unrelated config value was
changed).
Add the config value
```
foo[ca]=5
```
to any application config file. Start the application with locale ca_ES. Make
some changes to the configuration.
OBSERVED RESULT
The config file contains the line
```
foo[ca_ES]=5
```
instead of the original line.
EXPECTED RESULT
The original line is preserved.
Test function (for kconfigtest) to reproduce the problem:
```
void KConfigTest::testReadWriteOfLocalizedConfigValues()
{
// Initialize the testdata
QDir().mkpath(m_testConfigDir);
const QString file = m_testConfigDir +
QString::fromLatin1(QTest::currentTestFunction());
auto cleanup = qScopeGuard([&]() {
QFile::remove(file);
});
QFile f(file);
QVERIFY(f.open(QIODevice::WriteOnly));
QTextStream ts(&f);
ts << "[Test]\n";
ts << "foo=4\n";
ts << "foo[ca]=5\n";
ts << "foostring=primary\n";
ts << "foostring[ca_ES]=nice\n";
f.close();
// Load the testdata
QVERIFY(QFile::exists(file));
KConfig config(file);
config.setLocale(u"ca_ES"_s);
KConfigGroup cg(&config, u"Test"_s);
cg.writeEntry("bar", "barum");
config.sync();
const QList<QByteArray> lines = readLinesFrom(file);
qWarning() << lines;
QVERIFY(lines.contains("foo[ca]=5\n"));
QVERIFY(lines.contains("foostring[ca_ES]=nice\n"));
}
```
Note: I'll look into this myself.
--
You are receiving this mail because:
You are watching all bug changes.