summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
Commit message (Collapse)AuthorAgeFilesLines
* QFileSystemEngine: Consistently check for invalid file namesUlf Hermann2019-10-243-34/+75
| | | | | | | | | | | | | | stat() and friends expect a null-terminated C string. There is no way to generate anything useful from a string that has null bytes in the middle. It's important to catch this early, as otherwise, for example, a QDir::exists() on such a path can return true, as the path is silently truncated. Extend the checks for empty file names to windows and add checks for null bytes. Change-Id: Ie9794c3a7c4fd57f9a66bdbbab8b45a08b6f9170 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.13' into 5.14Qt Forward Merge Bot2019-10-241-22/+26
|\ | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qstandardpaths_unix.cpp src/corelib/tools/qsharedpointer_impl.h tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp Change-Id: Iae95c5778dc091058f16f6db76f04a0178a9e809
| * QStandardPaths: Correct handling for XDG_RUNTIME_DIRSamuli Piippo2019-10-121-23/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Always try to create the runtime directory and never change the permissions of an existing directory. Conform to the XDG Base Directory Specification: "If, when attempting to write a file, the destination directory is non-existent an attempt should be made to create it with permission 0700. If the destination directory exists already the permissions should not be changed." Fixes: QTBUG-68338 Change-Id: Iaf854d69225fc46e43abae86232d749e5c247df0 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Win32: Consolidate registry codeFriedemann Kleint2019-10-141-0/+2
| | | | | | | | | | | | | | | | Add a RAII class for registry keys and use it throughout the code base. Change-Id: I666b2fbb790f83436443101d6bc1e3c0525e78df Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-10-102-1/+4
|\| | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/xcb/qxcbscreen.h src/src.pro Change-Id: I4e1981e69a1ddcbe4078ec6ab2a64b0da6a445de
| * Include XDG font locations in QStandardPaths::FontsLocation on LinuxAlex Henrie2019-10-082-1/+4
| | | | | | | | | | | | | | | | | | | | ~/.fonts was deprecated in 2012, see https://wiki.archlinux.org/index.php/Font_configuration#Fontconfig_configuration Few people keep fonts there anymore. Change-Id: Ide048e1df2c2db4856a38c574df36663ab684f89 Reviewed-by: David Faure <david.faure@kdab.com>
* | Convert a few sizeof(array)/sizeof(element0) fors to range forsAlbert Astals Cid2019-10-041-4/+3
| | | | | | | | | | | | | | | | Increases readability Change-Id: I81ea915517fd2cd6bc2780f37ba8d8097c63f44b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-302-11/+78
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qrandom.cpp src/corelib/io/qfileinfo.cpp src/corelib/kernel/qeventdispatcher_win.cpp src/corelib/kernel/qeventdispatcher_win_p.h src/gui/text/qfontdatabase.cpp src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm src/plugins/platforms/windows/qwindowsglcontext.cpp src/testlib/qtestcase.cpp Done-With: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Done-With: Edward Welbourne <edward.welbourne@qt.io> Change-Id: I4893212471aa24be804c989a581810e2f714545c
| * QFileInfo: clarify documentation about handling of symlink attributesThiago Macieira2019-09-251-11/+75
| | | | | | | | | | | | | | | | | | | | On Windows, shortcut ".lnk" files are treated as symlinks, and attribute queries on a shortcut file return the results for the shortcut target. Fixes: QTBUG-77523 Change-Id: I907a43cd9a714da288a2fffd15bada7eba37d3ba Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
| * Filesystem: avoid crashes on exit in case the locale codec is nullThiago Macieira2019-09-241-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On exit, QLocale::codecForLocale() can return null as the codec may have already been destroyed. In that case, pretend that Latin1 was the locale, so any file name is acceptable. This matches QString: QTextCodec *codec = QTextCodec::codecForLocale(); if (codec) return codec->toUnicode(str, size); #endif // textcodec return fromLatin1(str, size); Note that if we're wrong and the locale was *not* Latin1, files that you had a name to may not be encoded or decoded the same way. Fixes: QTBUG-78446 Change-Id: Iece6e011237e4ab284ecfffd15c54077728a17ca Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | doc: add a note to QFileSystemWatcher about files saved by re-creationShawn Rutledge2019-09-231-0/+6
| | | | | | | | | | | | | | Fixes: QTBUG-46483 Fixes: QTBUG-53607 Change-Id: I434f177b35689d55aa1deea360bf7e6ae009ad68 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* | Fix mis-handling of actual TLD in qIsEffectiveTLD()Edward Welbourne2019-09-161-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the domain passed down is an actual TLD that's the subject of a * rule, e.g. "ck" subject to *.ck, then we were finding no dot in it and concluding that it couldn't be the subject of a * rule. Added a test for the specific .ck case and commented on where we could get some canonical test data that I tripped over while researching this. Cross-reference the cookie-jar test from the QUrl test, too. Fixes: QTBUG-78097 Change-Id: Id858a9dae22e6b306a68df3fc199e0160f537159 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add qt.core.filesystemwatcher logging categoryShawn Rutledge2019-09-111-4/+9
| | | | | | | | | | | | | | | | QFileSystemWatcher has open bugs, so users should be able to help troubleshoot. Change-Id: I6b703e25f294944469d20fd36012b6a55133732a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into 5.14Liang Qi2019-09-042-145/+136
|\| | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/codecs/qicucodec.cpp src/dbus/qdbusserver.cpp src/gui/painting/qbezier.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp src/plugins/printsupport/cups/qppdprintdevice.cpp Change-Id: I2703128bb64baf5580fbc2c2061b55b0f0611d2a
| * Docs: Some cleanup of class documentationKavindra Palaraja2019-08-271-140/+127
| | | | | | | | | | Change-Id: I62f89157e57189a97151f9661bc354af9bd67468 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
| * Also fall back to direct write for Android content: URLs in QSaveFileVolker Krause2019-08-241-5/+9
| | | | | | | | | | | | | | | | | | We cannot rename into content: URLs, so that is the only option, and this is particularly relevant here as the native file dialog will give us content: URLs by default for saving to. Change-Id: Ie96fcfc404a0842d397c7d1554e3c76f06bb3074 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Remove QFileInfo::type and related enum from 5.14Volker Hilsheimer2019-08-302-83/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The API is problematic for several reasons: - the mixing of flags and enum in a single enum type - the name "type" as somewhat overloaded - the ease of misuse when comparing the result rather than testing for a bit being set In light of this, focus for 5.14 on the new isShortcut and isSymbolicLink functions, thus migitating the problematic isSymLink which conflates the two concepts. Change-Id: I57e02321edd5061f69a775f04a0932ef89adf866 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | Merge remote-tracking branch 'origin/dev' into 5.14Liang Qi2019-08-271-27/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/widgets/kernel/qwidget.cpp src/widgets/kernel/qwidget_p.h src/widgets/kernel/qwidgetrepaintmanager.cpp src/widgets/kernel/qwidgetwindow.cpp tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp Change-Id: Ifae457d0427be8e2465e474b055722e11b3b1e5c
| * | forkfd: Add C11 and C++11 atomic supportThiago Macieira2019-08-201-27/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For forkfd, this is extremely useful, since users can rely on proper atomic API, not the old GCC API or the internal API that backs the C11 / C++11 implementation itself. This also caught one more mistaken use of seq_cst. Change-Id: Iec9c051acd73484c8d94fffd15b9985fe545e8b5 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* | | QtCore: port all QMutexLocker users to qt_{scoped,unique}_lockMarc Mutz2019-08-255-32/+38
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... except four instances in QCoreApplication that would conflict with another change. Replace a locally-defined MutexUnlocker with a call to unlock() + qScopedGuard'ed lock() to avoid having to spell out the locker type while we can't depend on C++17 CTAD, yet. In QSettings, move the new mutex locker into and out of initDefaultPaths(), such as is idiomatic for std::unique_lock, but wasn't possible with QMutexLocker (which is not movable). Change-Id: I23056e13ecaa76159db583c7dccc6e05715e0788 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Make Qt aware of symlinks and shortcuts on WindowsRyan Chu2019-08-162-15/+125
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt has traditionally considered Windows shortcut files equivalent to symlinks on Unix file systems. Because of NTFS symlinks, the interpretation of shotcut files as symlinks is confusing. In this change, QFileInfo treats shortcut (.lnk) files as regular files but can follow the pointed object. In addition, QFileInfo introduces a more comprehensive file type. So that applications can make well-informed decisions about how to treat a file system entry. Based on the implementation of QFileInfo::type(), two inline helper functions are introduced to QFileInfo. 1. isSymbolicLink, returns true if it points to a symbolic link. 2. isShortcut, returns true if it points to a shortcut. [ChangeLog][QtCore][QFileInfo] Introduce QFileInfo::type() to replace the isSymLink method. Task-number: QTBUG-75869 Change-Id: Icc0dd52f9ad0ea50b0265d77ee0d0a3d25054e39 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | QResource: port from QMutexLocker to qt_scoped_lockMarc Mutz2019-08-131-13/+13
| | | | | | | | | | Change-Id: I483e4765ef83d13e81bb830c9f48421410c5718b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QResource: consistently cache resourceList()Marc Mutz2019-08-011-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Each call to reourceList() uses atomic operations to check whether resourceGLobalData has not expired, yet. Some functions already cached the value, but then went on to use the function directly afterwards. In some cases, this was due to the cached value being a pointer-to-const and the function later deciding to mutate the list. But all the code is safe from detaches, so this distinction need not be made. Standardize on caching, and using the cached value, except in functions which call it only once. Change-Id: I79780b990da539bf7beaa8104e13cb8187f84812 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-08-011-1/+1
|\| | | | | | | Change-Id: I4505ec6fe17a1aa2c8d1e6576234d06a34eb9f99
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-311-1/+1
| |\ | | | | | | | | | Change-Id: Ifbaa4877051d93bcb0d58eed35bfe8dffa5634a3
| | * qfsfileengine_p.h: Un-inline processOpenModeFlagsOliver Wolff2019-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | An inlined exported function does not make sense and will cause a warning. Fixes: QTBUG-77242 Change-Id: I016b93d6b39c4db82148fdc5a8a92bc9d5751885 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-07-303-21/+40
|\| | | | | | | | | | | | | | | | | | | | Conflicts: qmake/generators/win32/mingw_make.cpp Change-Id: I2f790bc8572bd22fea01edf7ca74595b29f063eb
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-302-19/+36
| |\| | | | | | | | | | Change-Id: Ibdbd88e11cd03d5ce558e67ad8e9a21436e7ef89
| | * Move processOpenModeFlags out of QFSFileEngineOliver Wolff2019-07-292-19/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The same logic is needed for QWinRTFileEngine. To be able to reuse the code, it was moved out of the class. Task-number: QTBUG-77095 Change-Id: If52b2fc8a0f3056d32fc693775565a1c3803b7d4 Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-291-2/+4
| |\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qresource.cpp Change-Id: I54917f72444a621bd08aeaa15f5d17415993144d
| | * QResource: fix nullptr-check gone tautologicalMarc Mutz2019-07-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amends 136c5b9338f71775eb42528cfc7c23b2b4e5dff9. Before that change, each of the three members was a separate Q_GLOBAL_STATIC, so checking resourceList() for nullptr was the correct thing to do to find out whether the static was already destroyed. After the change, the resourceList() function will never return nullptr. Either resourceGlobalData.isDestroyed(), in which case dereferencing it asserts, or it isn't, in which case resourceList() returns a valid pointer. An explicit isDestroyed() check was added to the unregister function, but the register one was also checking resourceList() for nullptr, and this was left unprotected. Add the check and remove the now-tautological checks for nullptr resourceList(). Change-Id: I41fe66939ce858a77802b8af04c1de6e4fafe048 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | QStandardPaths: don't build a QHash just to look up one keyMarc Mutz2019-07-291-41/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code parses a file, looking for XDG_*_DIR entries and stores each one's key and raw value in a QHash. After parsing, it, however, looked up exactly once, by a key it could have known all along. So, move the key computation before the opening of the file, and look for the correct key directly, consciously striving to continue to find, as the old code implicitly did, the last entry, since man 5 user-dirs.dirs explains: > The format of user-dirs.dirs is designed to allow direct sourcing of > this file in shell scripts. Which means last one wins. Port to QStringView API of QRegularExpression, too. Change-Id: Ie92b689b5b9221df918c67b96f2f6a09827e7b1e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* | | Port from QStringViewLiteral to u""Marc Mutz2019-07-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Now that all our supported compilers know char16_t, we no longer need QStringViewLiteral, whose only purpose in life was to turn u"" into L"" for MSVC < 2015. Change-Id: I25a094fe7992d9d5dbeb4a524d9e99e043dcb8ce Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* | | Standardize on unique_ptr to hold QAbstractFileEngineMarc Mutz2019-07-285-22/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | This will make it possible to return it from functions in an owner, as exemplified in the QFileInfoPrivate ctor, unlike QScopedPointer, which lacks move special member functions. Change-Id: I179ffa4f656e1b83c23e0f67d1542834460ff382 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-07-221-2/+12
|\| | | | | | | | | | | | | | | | | | | | Conflicts: qmake/generators/makefile.cpp Change-Id: Ib3715e626f2fd32804c75c16ea9aa06a1216e76d
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-201-2/+12
| |\| | | | | | | | | | Change-Id: Ic34021fbb87d689ee23a5d1b3f50617ada9ec9b9
| | * Fix QStorageInfo inability to parse really long mountinfo linesThiago Macieira2019-07-191-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Docker creates really long lines due to the multiple levels of overlays in the overlayfs. Our limit of 1024 bytes was too short. [ChangeLog][QtCore][QStorageInfo] Fixed a bug that caused QStorageInfo to be unable to report all filesystems if the options to mounted filesystems were too long (over 900 characters, roughly), such as those found in Docker overlay mounts. Fixes: QTBUG-77059 Change-Id: I6aed4df6a12e43c3ac8efffd15b1ba4231e60b4a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | QFile: hold engine by unique_ptrMarc Mutz2019-07-195-53/+42
| | | | | | | | | | | | | | | | | | | | | | | | Unfortunately, we can't, yet, change QAbstractFileEngine::create() to return a unique_ptr. But we should do it in Qt 6. Change-Id: If18ff766bce73ecd4143274ac9f9a5a7b9d5912c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-191-1/+1
|\| | | | | | | | | | | Change-Id: I999ba23a27cd897017d15c6ffe41ea8cd008ffb9
| * | QStandardPaths: update docs to what $HOME is on iOSThiago Macieira2019-07-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | It's not <APPROOT> (any more, or was ever). Fixes: QTBUG-76911 Change-Id: I6aed4df6a12e43c3ac8efffd15aed22128862c23 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | | QDir: strip Windows' long-path markers when converting from nativeVolker Hilsheimer2019-07-171-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applications might receive paths with Windows' '\\?\' markers, which indicates a long path to Win32 APIs, when the application is opened by explorer via file association. Qt not ignoring those markers will fail to open such files. By stripping the marker in QDir::fromNativeSeparators, QFile, QFileInfo etc automatically are able to handle such paths. QDir::cleanPath is also documented to normalize separators, so it needs to be done there as well. [ChangeLog][QtCore][QDir] Remove Windows specific long path markers when handling file paths with native separators. Change-Id: I526a890614edee8c85b39fc12c98e7ddb6e0d793 Fixes: QTBUG-75117 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Merge "Merge remote-tracking branch 'origin/5.13' into dev"Qt Forward Merge Bot2019-07-172-3/+45
|\ \ \
| * | | Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-172-3/+45
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qlogging.cpp src/gui/painting/qtextureglyphcache_p.h src/gui/text/qfontengine.cpp src/widgets/widgets/qlineedit.cpp Change-Id: Ic8798538df466b7141caa8bbf1fb7605eb56be37
| | * | Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-132-3/+45
| | |\| | | | | | | | | | | | | Change-Id: I5d2a4fa33b4aa22da39ac045e6b85ab940b8720b
| | | * QSaveFile: Fix changing the file name after hitting on readonly fileFriedemann Kleint2019-07-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The call to QFileDevice::unsetError() in QSaveFile::open() does not clear QSaveFilePrivate::writeError. Clear it in addition. Fixes: QTBUG-77007 Change-Id: I5e5009750f1726d1c74c1b4eb1c33f3a5393fe4f Reviewed-by: David Faure <david.faure@kdab.com>
| | | * QDirIterator: don't require NFD normalization on Darwin for validityThiago Macieira2019-07-111-3/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HFS+ filesystems do enforce NFD normalization, so the test worked for those filesystems. But on APFS, the filesystem is normalization- insensitive but preserves it, so our transformation caused valid files to be rejected. This commit also optimizes the solution for all systems too. Instead of converting from 8-bit to UTF-16 then back to 8-bit (allocating memory in both steps), we only convert to UTF-16. And if we detect the locale is UTF-8, then we use the further optimized QUtf8::isValidUtf8 function that doesn't allocate any memory at all (ditto for US-ASCII, the case of someone running with LANG=C). Fixes: QTBUG-76522 Change-Id: Ief874765cd7b43798de3fffd15aa0d81620ad317 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | | QResource: deprecate isCompressed()Thiago Macieira2019-07-162-17/+34
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current codebases assume isCompressed() implies ZlibCompression, since there was no compressionAlgorithm() getter. In order to force codebases to change, deprecate isCompressed() and force handling of the algorithm. The replacement API is being introduced in 5.14, which is why the warning is being emitted in 5.15 only. Change-Id: Ief874765cd7b43798de3fffd15a9f5d978951ea5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | QProcessEnvironment: simplify lockingMarc Mutz2019-07-163-37/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The mutex is only protecting 'nameMap'. Proof: it's only defined on platforms on which there is a 'nameMap'. Also, nothing else is mutable, so no lazy init going on here. So, drop all the mutex protection, except where we access 'nameMap', and draw the mutex as close as possible to the nameMap uses, iow: copy ctor, prepareName() and nameToString(). As a consequence, the old (Ordered)MutexLocker class only needs to be defined on Unix. Change-Id: Ic969313bc48ad7ebf24c5dca7fd48359956b048d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Optimize QInotifyFileSystemWatcherEngine::getPathFromID()Marc Mutz2019-07-151-8/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code basically wants to get the last element of equal_range(id). The problem is that backwards iteration on QHash is very expensive, because it's implemented as forward search with wrap-around at bucket end. So it was implementing its own equal_range with look-ahead. The problem is that it compared each key in the equal_range twice: once in the if, and once more in the following while iteration. I expect to see this kind of algorithm more as we move away from the fake bidirectionalism of QHash, so I decided to implement it in a generic way. We can copy it somewhere else when we find more users. Change-Id: I7951652107ab897f6a456035f02e0339835e078d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* | | QFilesystemEngine: fix unused variable warning-turned-error on WASMMarc Mutz2019-07-131-0/+4
| | | | | | | | | | | | | | | | | | | | | ... and, presumably, Integrity. Change-Id: I54d35fd11b7df139022e2575c29b2d832f80f761 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>