summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
Commit message (Collapse)AuthorAgeFilesLines
* QProcess/Doc: update the information on how the program is foundThiago Macieira2022-03-101-13/+65
| | | | | | Pick-to: 5.15 6.2 6.3 Change-Id: I54f205f6b7314351b078fffd16d05b1eecb24544 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Add QFileInfo::isAlias() to reflect whether the file is a macOS aliasTor Arne Vestbø2022-03-062-2/+26
| | | | | | Change-Id: I772066d0d8e69893f7c4aee1cd2305d46d5834c4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Distinguish macOS aliases from normal symbolic linksTor Arne Vestbø2022-03-061-2/+7
| | | | | | | | | | | | | | | | | The deprecated Carbon function FSIsAliasFile() returned isAlias only for actual aliases, whereas the replacement CFURLCopyResourcePropertyForKey with kCFURLIsAliasFileKey returns true for both aliases and symbolic links. Since we didn't explicitly check for AliasType in any of our internal code, or or any of the public API, the distinction did not cause any issues, but if we want to expose QFileInfo::isAlias() we need to fix this. Pick-to: 6.2 6.3 5.15 Change-Id: I29f795d55fe40898de319aa1cb0a4a1b5646bbd6 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update QFileInfo docs to mention macOS aliasesTor Arne Vestbø2022-03-041-5/+7
| | | | | | | | | The LegacyLinkType reflected by isSymLink() includes QFileSystemMetaData::AliasType. Pick-to: 6.3 6.2 5.15 Change-Id: I98c84573f7f05d6d183b6ce1e22fc7424ed8e730 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QDebug: streamline (private) formatQFlagsGiuseppe D'Angelo2022-03-041-3/+2
| | | | | | | | | The implementation for extracting a QMetaEnum from an enumeration type was duplicated from QMetaType::fromEnum, just use that one. Also add an explicit cast for the valueToKeys call. Change-Id: I51b1a214dbab2101ae704954727acf0219eb1604 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Minor clean-ups noticed during string-parsing improvementsEdward Welbourne2022-03-031-4/+2
| | | | | | | | Simplify a conditional to save some repetition, purge some spurious parentheses. Change-Id: I727d22ce81733e765c4ee951475ccdb599063399 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QSettings: support reading UTF-8 keys in INI filesIvan Solovev2022-03-021-14/+18
| | | | | | | | | | | | | | [ChangeLog][QtCore][QSettings] The INI file reader now supports keys encoded with UTF-8, as well as the %-encoded format. Writing the keys back to the INI file is still done using %-encoded format. This change does not touch the way the *values* are handled - they are both read and written in UTF-8. Drive-by: remove misleading comments from the reading algorithm. Task-number: QTBUG-99401 Change-Id: I6a83cbf24d919a499540403688615f93cb195e93 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Make sure all qtbase private headers include at least one otherThiago Macieira2022-02-241-0/+2
| | | | | | | | | | See script in qtbase/util/includeprivate for the rules. Since these files are being touched anyway, I also ran the updatecopyright.pl script too. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Un-export QConfFileMarc Mutz2022-02-231-1/+2
| | | | | | | | | | Only clearCache() is used by tests. Ubsan build also passes. Makes it easier to reason about the mutex handling in the class' ctor and dtor. Change-Id: I917991cfecda71dcd0a5bea7705a7f7f3a3e75b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSettings: overload value() instead of using a default argumentMarc Mutz2022-02-203-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | ... of non-trivial type, which needs to be constructed every time the function is called, no matter whether the user supplies one or not. Effects on Linux AMD64 O2 C++20 tst_qsettings builds, as an example heavy-duty QSettings::value() user: GCC 11.2 libstdc++ (TEXT -= 4.6%): text data bss dec hex filename 662317 10952 2824 676093 a50fd tst_qsettings-00-baseline 631849 10960 2824 645633 9da01 tst_qsettings-01-qvariant Clang 10.0.0 libc++ (TEXT -= 2.8%) text data bss dec hex filename 808448 10616 2832 821896 c8a88 tst_qsettings-00-baseline 785890 10624 2832 799346 c3272 tst_qsettings-01-qvariant Pick-to: 6.3 Task-number: QTBUG-98117 Change-Id: I7366f063e3ec34c040fd35ffd274e8ed5a722132 Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix arguments of error message in QFile::copy()Friedemann Kleint2022-02-181-1/+1
| | | | | | | | | | Amends d34282dba0ebe67c16c1ee6e25d85f019b48b615. Task-number: QTBUG-100867 Pick-to: 6.3 Change-Id: I075908a51192084055b07ecaa38d9fe32a97a242 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix warnings in bootstrap lib on WindowsJoerg Bornemann2022-02-181-0/+3
| | | | | | | | | This amends commit 174af05400f6344a11f4aa2228244c954cbbca97. Pick-to: 6.3 Change-Id: Ifc11b3c332f2b7fd16074420a0d730997ae13395 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* QDebug: unexport most of the class for Qt 7Thiago Macieira2022-02-171-6/+5
| | | | | | | | Only a few helper methods need to be exported. Change-Id: I74249c52dc02478ba93cfffd16d2e8eac8a13182 Reviewed-by: Kai Koehne <kai.koehne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QIODevice::readAll: allow reading from a huge non-sequential devicesThiago Macieira2022-02-171-3/+4
| | | | | | | | | | | | | | | | | | | | | | On 32-bit systems, the non-sequential device could be pointing to a device of 2 GB or more in size. If so, we should allow reading up to the limit (2 GB - overhead), like we do for sequential devices in the block above. It could also happen on 64-bit systems, but the chance that you do have a file bigger than 8 EB is remote. [ChangeLog][QtCore][QIODevice] Changed readAll() handling of large non-sequential devices like files that are bigger than the maximum QByteArray size (on 32-bit systems, just under 2 GB). Previously, readAll() always returned empty; now it will attempt to read from the device. Task-number: QTBUG-100546 Pick-to: 6.3 Change-Id: I74249c52dc02478ba93cfffd16d1a14ac92c77bb Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QFile::copy: add the underlying error messages to oursThiago Macieira2022-02-161-2/+4
| | | | | | | | Fixes: QTBUG-100867 Pick-to: 6.3 Change-Id: Ic15405335d804bdea761fffd16d401a7c16f32f9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QIODevice::read: don't truncate to int(readBytes)Thiago Macieira2022-02-161-8/+8
| | | | | | | | | | | QByteArray in Qt 6 *can* hold more than 2GB-overhead of data. Untestable. Fixes: QTBUG-100546 Pick-to: 6.2 6.3 Change-Id: I74249c52dc02478ba93cfffd16d1a0ab398efe9c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QFileSystemEngine::canonicalName (Unix): clean up control-flowFabian Kosmale2022-02-151-20/+23
| | | | | | | | | | | | | | When passing a nullptr to realpath, it will allocate memory. That memory has to be freed (with free) later to avoid a leak, which we so far didn't. This patch ensures that we always clean up the memory by using a unique_ptr. As a drive-by, clean up the control-flow: - Always pass either the stack buffer or nullptr to realpath. - Rely on realpath returning nullptr in the error case. Lastly, fix a few coding-style issues. Change-Id: Ia906df77324020c267b087ec52a9a6c47aaa2a59 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QProcessEnvironment(Initialization) noexceptIevgenii Meshcheriakov2022-02-112-4/+16
| | | | | | | | | | | Use default noexcept constructor to initialize `d` member. Document Initialization enum. Fixes: QTBUG-100695 Pick-to: 6.3 Change-Id: I7585ad154a9be40021a205b515ffa7b14f188d67 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Avoid a stack buffer when not neededPino Toscano2022-02-111-0/+4
| | | | | | | | | | | | | Allocate a PATH_MAX-sized buffer on stack only in case we are not using realpath(X, null), i.e. on platforms with older POSIX versions, macOS, or Android. This fixes the build on platforms that do not have PATH_MAX (e.g. GNU/Hurd), and it provides a minor optimization on realpath(X, null) platforms. Change-Id: Icd92a1b15ec18c5eef8113408e9610dfac774101 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStandardPaths/Win: fix build with old MinGW SDKThiago Macieira2022-02-101-2/+4
| | | | | | | | | | | | | | | | | | ...that may lack GetCurrentProcessToken. The definition in the new SDKs is: FORCEINLINE HANDLE GetCurrentProcessToken (VOID) { return (HANDLE)(LONG_PTR) (-4); } This is a partial revert of ae7e11e5c6c0e8e9ae03bb8feecf4bcb2d85d72d. Pick-to: 6.3 Change-Id: I74249c52dc02478ba93cfffd16d23c487229f95d Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QUrl: use qOffsetStringArray for idn_whitelistMarc Mutz2022-02-091-10/+10
| | | | | | | | | | | | | | | | | | | | Removes 61 relocations from QtCore: before: $ ~/bin/relinfo.pl libQt6Core.so.6.4.0 libQt6Core.so.6.4.0: 6364 relocations, 5407 relative (84%), 318 PLT entries, 1 for local syms (0%), 0 users after: $ ~/bin/relinfo.pl libQt6Core.so.6.4.0 libQt6Core.so.6.4.0: 6303 relocations, 5346 relative (84%), 318 PLT entries, 1 for local syms (0%), 0 users Pick-to: 6.3 Task-number: QTBUG-100536 Change-Id: I29be3416eaacf7b2049d1e3eec15600d7e7c37c0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QSettings: use QtMiscUtils hex tools instead of rolling your ownMarc Mutz2022-02-091-6/+5
| | | | | | | | | Removes a static string literal. QtMiscUtils allows the compiler to possibly avoid the array, or share with other TUs Pick-to: 6.3 Change-Id: I449800f113620a53d2f4b11fe027ebcb710f7b86 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Unix: ensure we don't accidentally execute something from CWDThiago Macieira2022-02-091-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unless "." (or the empty string) is in $PATH, we're not supposed to find executables in the current directory. This is how the Unix shells behave and we match their behavior. It's also the behavior Qt had prior to 5.9 (commit 28666d167aa8e602c0bea25ebc4d51b55005db13). On Windows, searching the current directory is the norm, so we keep that behavior. This commit does not add an explicit check for an empty return from QStandardPaths::findExecutable(). Instead, we allow that empty string to go all the way to execve(2), which will fail with ENOENT. We could catch it early, before fork(2), but why add code for the error case? See https://kde.org/info/security/advisory-20220131-1.txt [ChangeLog][Important Behavior Changes] When passed a simple program name with no slashes, QProcess on Unix systems will now only search the current directory if "." is one of the entries in the PATH environment variable. This bug fix restores the behavior QProcess had before Qt 5.9. If launching an executable in the directory set by setWorkingDirectory() or inherited from the parent is intended, pass a program name starting with "./". For more information and best practices about finding an executable, see QProcess' documentation. Pick-to: 5.15 6.2 6.3 Change-Id: I54f205f6b7314351b078fffd16cf7013c97ee9fb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* doc: Update GenericDataLocation location on iOSTor Arne Vestbø2022-02-091-1/+1
| | | | | | | | | Now matches implementation. Fixes: QTBUG-100364 Pick-to: 6.2 6.3 5.15 Change-Id: I1274b8b485f1a02a79b7abebc2289613958f9a76 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess(Win): change int to qsizetype where appropriateMårten Nordheim2022-02-051-4/+4
| | | | | | | | | Even if it's unlikely any of those would exceed 2 billion entries. Pick-to: 6.3 6.2 Change-Id: Ib0d4d4e7a64fcde03b7f24bc0667d63c4a737deb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QBuffer: exterminate three thread-safe static guard variablesMarc Mutz2022-02-031-6/+11
| | | | | | | | | | | | | | | Instead of duplicating two dynamically-initialized statics each in two functions, causing four threading guards to be emitted by the compiler, pack the two variables into a static struct and the struct into an Extracted Method, leaving just a single threading guard. https://godbolt.org/z/a9e5o848f Uses C++14 NSDMI-in-aggregates, so doesn't work in 5.15. Pick-to: 6.3 6.2 Change-Id: I98e053df48aafd5720ceffd514d6811fd3b28b1a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QUrl: Use Q_CORE_REMOVED_SINCE instead of explicit version checksIevgenii Meshcheriakov2022-02-032-28/+3
| | | | | | | | | Use Q_CORE_REMOVED_SINCE macro for fromAce()/toAce() API changes. Pick-to: 6.3 Change-Id: I057c6d648c2141929f04e4b4c4a38ba3275261ab Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUrl: use qsizetype & size_t in place of int & uintThiago Macieira2022-01-282-73/+74
| | | | | | | | | | | Allows for URLs with more than 2 billion characters. I'm sure someone needs this... Change-Id: I0e5f6bec596a4a78bd3bfffd16c9991e4e6cacbf Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
* Fix build with clang-clYuhang Zhao2022-01-251-1/+1
| | | | | | | | | | | | | 1. Clang-CL can't recognize "/d2FH4" and it's causing lots of warnings when compiling. So don't apply it when building with clang-cl. 2. The definition of "FS_INFORMATION_CLASS" need to be visible to clang as well. Don't know why it was excluded originally. Pick-to: 6.3 Change-Id: I7b6e14999eea0ba1f0d73962ff03a35548f88a5a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] ↵Marc Mutz2022-01-214-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (QtGui) Create macros that wrap the magic developed in 7d63efc16f65f98c657caa90e0d7e9b72a879ade and apply it to all Q_DECLARE_METATYPE invocations that show up in Clang -ftime-trace for a PCH'ed QtGui build. Effects on compile times: Clang 10 -ftme-trace: $ ClangBuildAnalyzer --analyze qtgui-before.trace | head -n6 Analyzing build trace from 'qtgui-before.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 628.3 s Codegen & opts (backend): 304.5 s $ ClangBuildAnalyzer --analyze qtgui-after.trace | head -n6 Analyzing build trace from 'qtgui-after.trace'... **** Time summary: Compilation (523 times): Parsing (frontend): 546.0 s Codegen & opts (backend): 304.4 s GCC 11 time (bash builtin): before: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 4m13,539s user 49m24,416s sys 3m18,177s after: $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done real 3m55,697s user 45m19,941s sys 3m7,370s Task-number: QTBUG-97601 Pick-to: 6.3 Change-Id: Ia8e37a58937568a7ed21cfeb4b27274deca4d53b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtCore: replace qSwap with std::swap/member-swap where possibleMarc Mutz2022-01-207-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qSwap() is a monster that looks for ADL overloads of swap() and also detects the noexcept of the wrapped swap() function, so it should only be used when the argument type is unknown. In the vast majority of cases, the type is known to be efficiently std::swap()able or to have a member-swap. Call either of these. For the common case of pointer types, circumvent the expensive trait checks on std::swap() by providing a hand-rolled qt_ptr_swap() template, the advantage being that it can be unconditionally noexcept, removing all type traits instantiations. Don't document it, otherwise we'd be unable to pick it to 6.2. Effects on Clang -ftime-trace of a PCH'ed libQt6Gui.so build: before: **** Template sets that took longest to instantiate: [...] 27766 ms: qSwap<$> (9073 times, avg 3 ms) [...] 2806 ms: std::swap<$> (1229 times, avg 2 ms) (30572ms) after: **** Template sets that took longest to instantiate: [...] 5047 ms: qSwap<$> (641 times, avg 7 ms) [...] 3371 ms: std::swap<$> (1376 times, avg 2 ms) [qt_ptr_swap<$> does not appear in the top 400, so < 905ms] (< 9323ms) As a drive-by, remove superfluous inline keywords and template ornaments. Task-number: QTBUG-97601 Pick-to: 6.3 6.2 Change-Id: I88f9b4e3cbece268c4a1238b6d50e5712a1bab5a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QProcess/Unix: fallback on _POSIX_PIPE_BUF w/ missing PIPE_BUFPino Toscano2022-01-181-0/+5
| | | | | | | | | | | | | | | | | | | PIPE_BUF is optional in POSIX, e.g. "where the corresponding value is equal to or greater than the stated minimum, but where the value can vary depending on the file to which it is applied." [1] GNU/Hurd does not provide PIPE_BUF, so fallback to its minimum acceptable value, that is _POSIX_PIPE_BUF. [1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html Also, explicitly include <limits.h> in this file, to make sure PIPE_BUF or _POSIX_PIPE_BUF are available without relying on other headers to pull <limits.h>. Change-Id: Ifae964db81841e1d31fc09e73b45594af9a326d1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace QString::utf16 with QString::data where appropriateØystein Heskestad2022-01-172-2/+2
| | | | | | | | | | | QString::utf16() needlessly detaches fromRawData() to ensure a terminating NUL. Use data() where we don't require said NUL, taking care not call the mutable data() overload, which would detach, too. Task-number: QTBUG-98763 Change-Id: Ibd5e56798c0c666893c12c91ff0881842b8430c7 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QStorageInfo: limit Linux-only code with Q_OS_LINUXPino Toscano2022-01-161-0/+2
| | | | | | | | | This fixes a build problem (use of PATH_MAX) by eliminating a Linux-specific condition that can't happen on HURD anyway. Pick-to: 6.3 Change-Id: I5dcaf104a60b7850b8af3964fc4cd02ab24acd7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Mark QSP::PublicShare, Templates for 6.4Kai Köhne2022-01-141-2/+2
| | | | | | | | | The commit missed the 6.3 branching / feature freeze. Task-number: QTBUG-86106 Task-number: QTBUG-78092 Change-Id: I1d6b1efe0d482b6fc1ff3cfbbb440856b8cf1856 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QStandardPaths_win: Add mapping for DownloadLocationYuhang Zhao2022-01-131-8/+4
| | | | | | | | | Un-special-case for DownloadLocation. I assume the original code is written like that to be compatible with some really old versions of Windows. Change-Id: I643401910bae9a061f2e02c651971b4f2dd46901 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* QStandardPaths: Remove old MinGW workaroundYuhang Zhao2022-01-131-11/+1
| | | | | | | | | | | | | | | | From the comments the workaround is for MinGW older than v7, now our CI has MinGW v9 trunk, it should be safe to drop this. The magic number is replaced by the official function, although it was introduced in Win8, Qt6's minimum supported platform is Win10, so it's also safe to do. As a drive-by, remove two unused includes. Change-Id: I891fe3883f17d4914932784868d7446299d32c65 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QStandardPath: fix typoYuhang Zhao2022-01-131-1/+1
| | | | | | Pick-to: 6.3 6.2 Change-Id: I12837ce614ea91a8a72191092dc8c835f74107cc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Doc: Replace "C:\Documents and Settings" pathsKai Köhne2022-01-121-1/+1
| | | | | | | | | | "C:\Documents and Settings" isn't a real path anymore since Windows Vista. Replace it by C:\Users, or - in the snippet for QDesktopServices that is for demoing a path with space - with C:\Program Files. Pick-to: 6.2 6.3 5.15 Change-Id: I1bef97b6482180a6467fffcd1d62d6c168bcb389 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace QString::utf16() with data() in memcpy() and QByteArray ctorØystein Heskestad2022-01-072-4/+4
| | | | | | | | | | | QString::utf16() needlessly detaches fromRawData() to ensure a terminating NUL. Use data() where we don't require said NUL, taking care not to call the mutable data() overload, which would detach, too. Task-number: QTBUG-98763 Change-Id: I7075a8f18ab1f82ebbcf8cfab1643e8ab7f38d51 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add PublicShare and Templates QStandardPathsBjörn Feber2022-01-017-2/+63
| | | | | | | | | | | | | | | | | These directories are common on desktop operating systems. "Public" is used for sharing files with other users and "Templates" lets you add new files to the file creation desktop menu (for example in a file manager). An example use in a Qt application would be KDE's KIO having default icons for both directories. This is where they point to: Windows: C:/Users/Public, C:/Users/<USER>/AppData/Roaming/Microsoft/Windows/Templates macOS: ~/Public, ~/Templates Unix: ~/Public, ~/Templates Task-number: QTBUG-86106 Task-number: QTBUG-78092 Change-Id: Ifca60c7d2a6dc2109ec290e8fb109ee2d5ca4d38 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Docs: Add other Unix paths to the Linux table in QStandardPathsNicholas Bennett2021-12-301-1/+1
| | | | | | | | | | | | Added Unix to the title of the enum QStandardPaths::StandardLocation docs Linux paths table as this also aplies to Unix based OS's such as QNX. Fixes: QTBUG-63695 Pick-to: 6.2 6.3 Change-Id: I37b1bb6167984ccf7877baf2e6e764337121a947 Reviewed-by: Tommi Mänttäri <tommi.manttari@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Windows: Fix handling of childGroups() when fallbacks are disabledJeremie Graulle2021-12-271-4/+10
| | | | | | | | | | When fallbacks are disabled for QSettings then it should not be falling back to any child groups or keys that might exist in a fallback set of settings. Fixes: QTBUG-85295 Change-Id: I563999293a103702035c8d3b027b59b94ca43c0e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make QRingBuffer a move-only typeMarc Mutz2021-12-161-5/+9
| | | | | | | | | | | | There's no sense in copying a ring buffer. Moving is enough. This marks an important step on the way to preventing accidental copies of ring buffer content, because the 'QList buffers' member can now no longer be implicitly shared. While the compiler will still emit the code for detach()ing, it will now never be executed. Pick-to: 6.3 Change-Id: I968bfe3e50c46720ed4baca55c99c1f9c518f653 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QIODevice: use QVLA to hold the ring buffers, not QListMarc Mutz2021-12-151-3/+3
| | | | | | | | | | | | | | | The only users of more than one read- or write channel are the SCTP code and QProcess. SCTP being pretty rare, optimize for the common case of at most two QRingBuffers for reading (QProcess) and one for writing. Even with more channels, QVLA shouldn't be slower than QList - on the contrary. Need to adjust tst_toolsupport and TypeInformationVersion, as QFilePrivate::fileName has changed. Pick-to: 6.3 Change-Id: I3baf982ba1f4dc51463be8730e414f6164072d8b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNX: Fix QLockFile supportPasi Petäjäjärvi2021-12-141-1/+21
| | | | | | | | Implement getting pid by process name and enable using flock(). Pick-to: 6.2 Change-Id: I500e645b451baddea788d834374a7ae29a4d223f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLockFile/Linux: skip QFileInfo if we're just doing string manipulationThiago Macieira2021-12-111-1/+2
| | | | | | | | | | | Avoids a lot of overhead. Could be even simpler, but we don't need to duplicate QFileSystemEntry. Pick-to: 6.2 Change-Id: Ib42b3adc93bf4d43bd55fffd16beda971e4b2ae7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Igor Kushnir <igorkuo@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Remove redundant QDir::fromNativeSeparators() callIgor Kushnir2021-12-111-1/+1
| | | | | | | | | | | | QFileSystemEntry::QFileSystemEntry(const QString &filePath) already calls this function. Calling it repeatedly changes nothing but wastes CPU time. Neither the line modified in this commit nor the QFileSystemEntry's constructor have been changed since 2011's commit "Initial import from the monolithic Qt." Other constructor overloads of QFileInfoPrivate don't call QDir::fromNativeSeparators(). Change-Id: I01e54662efd96e87c4a686369dc0b265b47e5938 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Implement fetching physical QStorageInfo::blockSize() under WindowsKarsten Heimrich2021-12-083-1/+239
| | | | | | | | | | | | | | | | | | This is implemented in two passes, first we try the older and always available DeviceIoControl() function. This works most of the time, though it might fail for example for storage devices attached via USB. In this case, we try to dynamically load the newer NtQueryVolumeInformationFile kernel function. Since this is probably more expensive, we do this as fallback. [ChangeLog][QtCore][QStorageInfo] The QStorageInfo::blockSize() will now report the physical block size of a storage device under Windows. Network mapped drives are not supported. Fixes: QTBUG-93976 Change-Id: I08b5b879e5bf79c025e2e305196ec5c5fce8b20f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QFile: Add open() overload that accepts permissions argumentIevgenii Meshcheriakov2021-12-042-1/+49
| | | | | | | | | | | | | | | The new overload allows creation of files with non-default permissions. This is useful when files need to be created with more restrictive permissions than the default ones, and removes the time window when such files are available with less restrictive permissions. [ChangeLog][QtCore][QFile] Added QDir::open() overload that accepts permissions argument. Fixes: QTBUG-79750 Change-Id: Iddfced3c324e03f2c53f421c9b31c76dee82df58 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>