aboutsummaryrefslogtreecommitdiff
path: root/src/core/kconfigini.cpp
AgeCommit message (Collapse)Author
2022-08-19General code clean-upAhmad Samir
- use the strings in a QStringList directly - slightly better readability: less if-else-nesting, return early GIT_SILENT
2021-09-29Android: Fix writing to config if path is a content:// UriSharaf Zaman
KConfigIniBackend relies on QLockFile which changes the content Uri and this is bound to fail because we don't have permission. So, for these Uris we use Android's Internal cache directory to save the .lock files.
2021-09-19kconfigini: Only open the file once to writeAleix Pol
We were calling open(), then fopen(), then QFile::open(). This patch removes the fopen() call that does not seem to do anything.
2021-08-28GIT_SILENT: we can use std::as_const directlyLaurent Montel
2021-08-13clang-tidy: one declaration per line; braces around statementsAhmad Samir
clang-tidy checks: readability-isolate-declaration and readability-braces-around-statements KF task: https://phabricator.kde.org/T14729 GIT_SILENT
2021-08-03KConfig: fix deletion of an entry that is also in kdeglobalsDavid Faure
This is the case where we expected to see Key[$d] in the config file, and it was somehow broken. When saving, the key was omitted, so when reloading the kdeglobals key was present again. Detected when trying to write a unittest for a different patch... I had to reshuffle the unittest a bit because testThreads calls testSimple which didn't expect that the "[AAA]" group would actually be deleted now.
2021-07-05Do not create a vector and a QByteArray just to discard it immediatelyAleix Pol
2021-07-05Only query for existing config file when it's necessaryAleix Pol
We are only interested in whether the file doesn't exist when it fails to open. This saves a stat on every successful config file parse.
2021-04-15KConfig: rename kconfigdata.h to kconfigdata_p.hDavid Faure
It's internal, the symbols are not exported, the header is not installed. The _p.h naming makes this more obvious, when grepping for stuff in public API.
2021-03-06Minor code optimisationAhmad Samir
- Use more range-for loops where appropriate - Use auto instead of the usually-long iterator type names - Use cbegin/cend(), to match the std:: containers, less confusion - Use qDeleteAll instead of a for loop - Make a QRE with a long-ish pattern static NO_CHANGELOG
2021-03-06Optimise string operations a bitAhmad Samir
- Use QString::arg(Args...) instead of .arg().arg() - Use QLatin1String for string comparisons, should be faster - Use QLatin1String::arg() for better readability - Add the comment dfaure suggested in the MR, to explain why it's '2%' then '%1' in a QString().arg().arg() NO_CHANGELOG
2021-02-22Fix formatting in a couple of places after running clang-formatAhmad Samir
NO_CHANGELOG
2021-02-22Run clang-format on all cpp/h filesAhmad Samir
NO_CHANGELOG
2021-02-06Preincerment/predecrement operator where the post ones aren't neededAhmad Samir
NO_CHANGELOG
2020-07-07Use camelcase include. (scripted)Laurent Montel
2020-04-17Add force save behavior to KEntryMapBenjamin Port
Summary: Fix the following bug, if an entry is set on HOME/.config/kdeglobals and on a specific config file like kcmfonts When you hit restore defaults button and apply, value will be not wrote on the specific file, but then the value is the one from kdeglobals This patch ensure we write the key to the specific configuration file on those case with an empty value. KConfig will take default value automatically Test Plan: Added a test to ensure flag is working Tested using some KCM to ensure all is working fine Reviewers: ervin, dfaure, meven, crossi, hchain Reviewed By: ervin, dfaure, meven Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D28128
2020-03-22KConfig: Convert to SPDX license statementsAndreas Cord-Landwehr
Summary: Convert license headers to SPDX statements and add license files as required by REUSE specification. Reviewers: cgiboudeaux Reviewed By: cgiboudeaux Subscribers: ognarb, cgiboudeaux, kde-frameworks-devel Tags: #frameworks Maniphest Tasks: T11550 Differential Revision: https://phabricator.kde.org/D27601
2019-12-04Don't use nullptr as flag. Make it compile against qt5.15Laurent Montel
2019-08-28GIT_SILENT: use QLatin1StringLaurent Montel
2019-08-14Add a logging category for logs warningsMéven Car
Summary: Disable logs unless the logging category kf5.kconfig.core is enabled Test Plan: ctest Reviewers: #frameworks, apol, cgiboudeaux Reviewed By: cgiboudeaux Subscribers: cgiboudeaux, mikeroyal, apol, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D22061
2019-03-11Remove reference from const KConfigIniBackend::BufferFragment &Albert Astals Cid
Summary: According to clazy since KConfigIniBackend::BufferFragment is very small it's faster to just copy it Reviewers: apol Reviewed By: apol Subscribers: apol, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D19666
2019-03-03[Kconfig] Compile without foreachLaurent Montel
Summary: compile without foreach Test Plan: Unittest Ok as previously Reviewers: dfaure Reviewed By: dfaure Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D19326
2019-02-20Write valid UTF8 characters without escaping.Jos van den Oever
Summary: commit 6a18528 introduced escaping of bytes >= 127 to ensure that KConfig files are valid UTF8. The simplistic approach with a cutoff results in many escaped bytes where it is not required. Especially non-western configuration files would have many escapes. This commit fixes that by only escaping bytes that are not valid UTF8. BUG: 403557 FIXED-IN: 5.56 Test Plan: ninja && ninja test Reviewers: dfaure, arichardson, apol, #frameworks, thiago Subscribers: rapiteanu, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D19107
2019-02-04KConfig: handle directory symlinks correctly.David Faure
Summary: When /home is a symlink, for instance (as is often the case on FreeBSD), group deletion would fail because KConfig was comparing non-canonical paths with canonical-paths: QDEBUG : KConfigTest::testDelete() Comparing "/home/adridg/.qttest/config/ kconfigtest_subdir/kconfigtest" and "/usr/home/adridg/.qttest/config/ kconfigtest_subdir/kconfigtest" Test Plan: mkdir /tmp/derp; ln -s /tmp/derp /tmp/drop HOME=/tmp/derp bin/kconfigtest testDelete # Success HOME=/tmp/drop bin/kconfigtest testDelete # Fail Reviewers: adridg, arichardson, apol Reviewed By: apol Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D14927
2018-12-30Fix a regression introduced in 6a1852Jos van den Oever
Summary: Bytes from 'Strings' of type GroupString and KeyString should not be escaped because they are valid UTF-8. Only instances of ValueString should be escaped. This fixes the failing test KConfigTest::testEncoding Test Plan: Ran `ninja test` and found no errors. Reviewers: dfaure, arichardson, apol, aacid, ngraham Reviewed By: apol Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D17856
2018-12-18Escape bytes that are larger than or equal to 127 in config filesJos van den Oever
Summary: UserBase tells me that KDE configuration files are encoded in UTF-8. https://userbase.kde.org/KDE_System_Administration/Configuration_Files In practice some *rc files have bytes outside that encoding. In my home directory I found two files that are not valid UTF-8. I searched with find ~/.config/ -name '*rc' -exec file {} + which gives these exceptions: akonadiconsolerc: Non-ISO extended-ASCII text, with very long lines kmail2rc: Non-ISO extended-ASCII text, with very long lines In kmail2rc, the offending fields are [AttachmentView]/State [CollectionFolderView]/HeaderState Both are QByteArray values saved from QHeaderView::saveState(). In the instance I found, the offending bytes were 0x81 and 0x84. akonadiconsolerc had way more of these values. All seem related to saving widget state and hence probably QByteArrays. The written QByteArray values look very strange. The bytes in the non-printable ASCII range are written as \xXX but the values above 127 are written literally. The encoding is done by KConfigIniBackend::stringToPrintable. It does not currently escape bytes that are larger than or equal to 127. Reviewers: dfaure, arichardson, apol Reviewed By: apol Subscribers: apol, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D17651
2018-09-28 Fix issue when reading path listsAleix Pol
Summary: They were not being split properly. Test Plan: Tests pass, including the new one. Reviewers: #frameworks, dfaure Reviewed By: dfaure Subscribers: dfaure, anthonyfieroni, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D14162
2017-08-08kconfigini: Strip leading whitespace when reading entry values.Michael Pyne
As per the Desktop Entry spec, we strip trailing whitespace from the key when we split an entry into a key/value pair at the '='. Now we also strip leading whitespace from the resulting value like we should. CCBUG:310674 Differential Revision: https://phabricator.kde.org/D7169
2017-03-15Remove unused QDateTime in KConfigBackend.David Faure
Spotted because it leads to race conditions due to tzset (surely a Qt bug, but anyway no point in finding out lastModified for nothing). While at it, remove the unused size field as well.
2017-03-15Now that kconfigbackend.h isn't installed anymore, rename it to _p.h for ↵David Faure
clarity.
2017-03-05avoid useless reallocs by removing squeeze call on temporary bufferChristoph Cullmann
Differential Revision: https://phabricator.kde.org/D4941
2017-01-16Prefer nullptr over Q_NULLPTRKevin Funk
2017-01-16Use nullptr everywhereKevin Funk
Differential Revision: https://phabricator.kde.org/D3987
2016-02-19KConfigIniBackend: Fix expensive detach in lookupKevin Funk
Differential Revision: https://phabricator.kde.org/D990
2015-10-05Minor optimizationsAlbert Astals Cid
Ran the clazy tool (http://www.kdab.com/use-static-analysis-improve-performance/) Mostly QStringLiteral/QLatin1String additions A few const & additions to non public methods Compiles, test pass REVIEW: 125106
2014-07-01Fix reading of XDG style semicolon separated lists with escaped ';'Alex Richardson
Previously the warning "Invalid escape sequence "\;"." would appear and "\;" was replaced with just the backslash as is done for all unrecognized escape sequences. Keep both characters so that readXdgListEntry() works with values containing semicolons REVIEW: 119074
2014-07-01Remove register keyword since it is deprecatedAlex Richardson
2014-06-21Fix reading of entries for language/country combinationsMartin Gräßlin
This fixes a regression introduced in 988f09bb051dca0437ecec431ee44ed5b4a560d8. The mentioned commit ensures that if the locale is e.g. "de_DE" the entry "de" will be used. But this breaks if there is a translation for another country. E.g. for "de_CH" it would also pick the "de" entry. This change now operates on both just the language code and the locale. If an entry with the language code is present it will be picked. If another entry with the exact locale is found it will be overwritten. Modifiers are not supported as this is currently missing in QLocale. REVIEW: 118692
2014-06-19Optimize KConfigIniBackend::parseConfig by reducing allocations.Milian Wolff
Yet another awesome application of the Qt implicit sharing trick. Since config files often contain only few different keys and even value strings, we can share them. This reduces memory consumption and also speeds up parsing, as we do not have to allocate the duplicated strings, but can simply reuse the previous values. The most extreme case for this of my knowledge, is KatePart: katesyntaxhighlightingrc has more than 20k lines which triggered nearly 30k allocations on startup. With this patch applied, this value goes down dramatically. I added a simple static counter for the cache hit/miss ratio, which resulted in 5442 cache misses compared to 43624 cache hits across all KConfig files parsed by kwrite. REVIEW: 118587 This is a forward-port of b8aaeff128233cfaecf67899168887572589dde8.
2014-06-12Simple CleanupsThomas Braxton
- use Q_NULLPTR instead of 0 or NULL - simplify some foreach loops - use QStringLiteral in a few places - added a few consts REVIEW: 118666
2013-12-30Revert "Workaround corrupted lock files"David Faure
This reverts commit c15e319455b7e93439eb445e2e2670ec3122e697. The real fix is in Qt, let's go back to using lock() here, as intended by QLockFile.
2013-12-18Code reformatted using kde-dev-scripts/astyle-kdelibs.David Faure
Use git blame -w 867e7a5 to show authorship as it was before this commit.
2013-12-18Move kconfig code to the root directory.Jenkins CI