summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
Commit message (Collapse)AuthorAgeFilesLines
* Make QFileSystemEngine::canonicalName use the realpath function on VxWorksŁukasz Matysiak4 days1-1/+1
| | | | | | | | | | | | | | Despite realpath being available on VxWorks (when the INCLUDE_IO_REALPATH component is used in the VIP), canonicalName doesn't use it, because the system reports _POSIX_VERSION as 200112. Fix the problem by adding an additional condition so that VxWorks correctly uses realpath. Pick-to: 6.7 Task-number: QTBUG-115777 Change-Id: I734f525e870f93a7ec955d379dcc2137b591e171 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QResource: add support for duplicating mapped memory on macOSThiago Macieira7 days1-0/+22
| | | | | | | | | | | | | | | Similar to the Linux solution, this avoids allocating heap memory in the implementation of QFile::map() calls with MapPrivateOption. Unlike the Linux solution, the macOS one cannot duplicate resources present in read-only sections of binaries, only those loaded from files with mmap() (QResource::registerResource()), because the max_prot setting on the source does not have the VM_PROT_WRITE bit set and I could not find a way to reset it to force a copy-on-write. Change-Id: I6979d02a7395405cbf23fffd17c951949c71ec20 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QResource: add support for duplicating mapped memory on LinuxThiago Macieira7 days1-3/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | This makes QResourceFileEngine avoid allocating heap memory in the implementation of QFile::map() calls with MapPrivateOption. We do that by asking the kernel to duplicate the mapping to the same memory pages, which increases our virtual memory space but doesn't initially take up any more RAM. We have to be careful to ensure the resulting mapping is copy-on-write and that this setting is independent of the original map's. The former is easy: the mremap() system call with MREMAP_DONTUNMAP only works on private memory blocks, so by definition any private + writable block is copy-on-write. The latter is slightly more difficult: if the original block was already writable, then the kernel could give us a new map to the exact same pages[*], which isn't exactly helpful. Therefore, we need to check if the QResourceRoot points to a private, read-only block. [*] in those conditions, mremap() is documented to replace the original mapping with a zero page, which means we have a near certainty of crashing, instead of accidentally, silently corrupting memory. Change-Id: I6979d02a7395405cbf23fffd17c90fb1f1612ed7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QBuffer: resolve todo / use QByteArray::assignMårten Nordheim7 days1-2/+1
| | | | | | | | | It no longer lacks assign Change-Id: Ib96dec54e8d9fd0f182a9a26692a5504993fb622 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Dennis Oberst <dennis.oberst@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QResource: add support for memory mapping on WindowsThiago Macieira11 days1-0/+16
| | | | | Change-Id: I6979d02a7395405cbf23fffd17c90b446cba1486 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QResource: re-factor the memory-mapping code into two helper functionsThiago Macieira11 days1-41/+47
| | | | | | | So I can more easily extend to Windows support and to reuse them later. Change-Id: I6979d02a7395405cbf23fffd17c90b32dbbddd94 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QResource: move the internal classes to unnamed namespacesThiago Macieira11 days1-1/+6
| | | | | | | | | | So the compiler has more opportunities to inline and to not emit out-of- line copies. Pick-to: 6.7 Change-Id: I6979d02a7395405cbf23fffd17c9101b2b52472a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QResource: obey the MapPrivateOption option to provide RW memoryThiago Macieira11 days1-1/+16
| | | | | | | | | | | | | | | | | | | | | The documentation says: The mapping will have the same open mode as the file (read and/or write), except when using MapPrivateOption, in which case it is always possible to write to the mapped memory. So obey it. This may cause high memory use by copying data we already have. This may be important because applications may want to memory-map resources which they intentionally didn't compress because those resources are large. Later commits will implement some workarounds. Fixes: QTBUG-124608 Pick-to: 6.7 6.6 6.5 Change-Id: I6979d02a7395405cbf23fffd17c8f03baf0ec00d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QResource: simplify map() to rely on the uncompressed data being thereThiago Macieira11 days1-7/+8
| | | | | | | | | We can only call map() if we've already called open() and that will decompress the data. Pick-to: 6.5 6.6 6.7 Change-Id: I6979d02a7395405cbf23fffd17c8f1f77ca92b2b Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QResource: use qint64 for lastModifiedThiago Macieira2024-04-261-4/+4
| | | | | | | | We pass it to QDateTime::fromMSecsSinceEpoch, which is signed. Change-Id: I6979d02a7395405cbf23fffd17c992674c6321fc Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QResource: remove unnecessary mutable markersThiago Macieira2024-04-261-4/+4
| | | | | | | | | | | These are all modified by ensureInitialized() and ensureChildren(), which are const. However, ensureInitialized() does a const_cast<> on the object before calling non-const load(), which is where these are modified. Change-Id: I6979d02a7395405cbf23fffd17c992546ecbda49 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QSaveFile: don't reset fileEngine after commit()David Faure2024-04-261-4/+4
| | | | | | | | | | | [ChangeLog][QtCore][QSaveFile] Member functions such as fileTime() and size() now continue to work after commit(). Fixes: QTBUG-66605 Fixes: QTBUG-77039 Change-Id: I0b17eae9493911d1a0828b589d762bd8eb344bce Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add the missing include of termios.hAlexey Edelev2024-04-261-0/+1
| | | | | | | | The include unlocks the usage of the TIOCNOTTY constant. Fixes: QTBUG-124642 Change-Id: Ife2475626ca61efe38ea7928a9b61a8aded1701d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAbstractFileEngine member classes: sort out constructionEdward Welbourne2024-04-242-8/+11
| | | | | | | | | | | | | | | | | QAbstractFileEngine::(Un)?MapExtension(Option|Return) didn't initialize their members in their default constructors. The two Option types were each insantiated in one place that set each field, so give them overt constructors taking the field values. For the Return type, apply NSDMI to its one data member. The code using it does ignore the data member unless extension() succeeds, but a derived class that wronlgy neglects to set it while succeeding would have caused trouble. Disable copy and move for all three, overtly declare the default constructor for the Result. Task-number: QTBUG-122619 Change-Id: I4b30d383c59e52735d54d9f709c532d504bdea60 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QProcess: fix startCommand() with whitespace-only stringsThiago Macieira2024-04-191-0/+4
| | | | | | | | | | | | | | We'd end up trying to takeFirst() from an empty QStringList. [ChangeLog][QtCore][QProcess] Fixed a bug that would cause startCommand() to crash if passed a string that was empty or contained only whitespace characters. Fixes: QTBUG-124512 Pick-to: 6.5 6.6 6.7 Change-Id: I455fe22ef4ad4b2f9b01fffd17c7689095c39272 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QTemporaryFileEngine: minor optimizationAhmad Samir2024-04-201-2/+1
| | | | | | | | | | The original code updated d->fileEntry twice in a row: it assigned to it directly, then called QFSFileEngine::setFileName() which assigned to d->fileEntry again. Now only one QFileSystemEntry is constructed. Change-Id: I3cdc131b97455c14e5b032fbdecdae0eaa32925f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFSFileEngine: update d->fileEntry after a successful renameAhmad Samir2024-04-204-8/+27
| | | | | | | | | | | | | | | | | | | | | | | Otherwise member methods such as size() could return incorrect info. Add setFileEntry(QFileSystemEntry &&); to reuse a QFileSystemEntry if we have already constructed one. As a result of this, a QTemporaryFileEngine::setFileName() call has become redundant and can be removed; the code it executed is already taken care of: - QFSFileEngine::close(): already called by QTFEngine::rename() a couple of lines above - QFSFileEngine::setFileName(): QTFEngine::rename() calls QFSFileEngine::rename() which in turn updates the `fileEntry` This commit is covered by tst_QTemporaryFile::rename(), i.e. if QFSFileEngine::rename() didn't update the fileEntry, that test would fail. Change-Id: I312f35cf7fdf9b1a8cd0bce5e98ba7a48cf9426e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Disable copy and move of QAbstractFileEngineHandlerEdward Welbourne2024-04-192-0/+4
| | | | | | | | | | | | They're not wanted and Axivion (SV71) grumbles about the lack of copy and move operators and constructors otherwise. Do the same in all derived classes. Some of these needed their default constructors made overt as a result. Similar for QAbstractFileEngineHandlerList. Task-number: QTBUG-122619 Change-Id: Iff016940f8c4884bd65dd781354b9bcda9b7cdd8 Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QFSFileEngine: de-duplicate some codeAhmad Samir2024-04-192-19/+15
| | | | | | | | | | | The only difference is the name of the QFileSystemEngine method each one calls. This makes subsequent commits simpler, since now only one function will need to be changed. Change-Id: I1b7d2ceeab0ad98e2ee87b3a64f100ab906f7df5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QInotifyFileSystemWatcherEngine: change to QObject::connect PMF syntaxJuha Vuolle2024-04-181-1/+2
| | | | | | Task-number: QTBUG-122619 Change-Id: I624d282791a561ebd0d70cadc9bf17594cc1eb5c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNonContiguousByteDevice private classes: add Q_OBJECT macroJuha Vuolle2024-04-181-0/+3
| | | | | | Task-number: QTBUG-122619 Change-Id: If50e051d5c6eed04ed03a97f0a1dafc7b47d551e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QByteDeviceWrappingIoDevice: change to use QObject::connect PMF syntaxJuha Vuolle2024-04-181-1/+1
| | | | | | | Task-number: QTBUG-122619 Change-Id: I1128f2bd42ba6dc1227e62264427418ecbf80b27 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QSaveFile[win]: remove fallback to old renameOverwriteMårten Nordheim2024-04-171-4/+3
| | | | | | | | | | | | Our new way of doing it is atomic, so while conflicts can still happen that leads to e.g. access denied, those will be because the _target file_ is already accessed for some reason. The fallback might be lucky enough that it happens after this other access is done, but probably not. So remove the fallback and just do the atomic rename. Change-Id: I13f6b4b70974500b8dd9309138b9052b6a5acc62 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSaveFile[win]: store error in nativeRenameOverwriteMårten Nordheim2024-04-171-4/+4
| | | | | | | | We want to drop the fallback path, so we need to set an appropriate error when the native rename fails. Change-Id: I2746d79b9e5666f54c35ff7ac29a74191cf22740 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSaveFile[win]: only use SetFileInformationByHandle when opened with DELETEMårten Nordheim2024-04-171-3/+5
| | | | | | | | | | | | SetFileInformationByHandle only works when we have opened the file with DELETE access. Since the code is shared with QTemporaryFile it is not necessarily always a given. Since it was anyway falling back to the old way of doing it it was not a problem, but it is cleaner to only use it when we know it will work. Pick-to: 6.7 Change-Id: I3c744734d45272c41e49bb6971adf4f82213d97d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSaveFile[win]: remove const from nativeRenameOverwriteMårten Nordheim2024-04-172-2/+2
| | | | | | | | | | I accidentally copied const from another signature. It's not changing any members so it's technically fine, but it leaves a bad feeling and we will change members soon. Pick-to: 6.7 Change-Id: Ib0236d7e7dda84834ba35907d75c52cf77fb3843 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Long live [[nodiscard]] QFile::openGiuseppe D'Angelo2024-04-178-11/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Having already caught some bugs in real code because of unchecked calls to QFile::open, this commit marks QFile::open (and open() in other file-I/O classes) as [[nodiscard]]. Since it's going to raise warnings, the plan is to keep the existing behavior up to and including the next LTS. Then the warnings will switch on by default. All of this is protected by system of macros to opt-in or opt-out the behavioral change at any time. A possible counter-argument for doing this is that QFile::open is also used for opening files in the the resource system, and that opening "cannot fail". It clearly can, if the resource is moved away or renamed; code should at a minimum use a Q_ASSERT in debug builds. Another counter-argument is the opening of file handles or descriptors; but again, that opening may fail in case the handle has been closed or if the flags are incompatible. --- Why not marking *every* open() override? Because some are not meant to be called directly -- for instance sockets are supposed to be open via calls to `connectToHost` or similar. One notable exception is QIODevice::open() itself. Although rarely called directly by user code (which just calls open() on a specific subclass, which likely has an override), it may be called: 1) By code that just takes a `QIODevice *` and does something with it. That code is arguably more rare than code using QFile directly. Still, being "generic" code, they have an extra responsibility when making sure to handle a possible opening failure. 2) By QIODevice subclasses, which are even more rare. However, they usually ignore the return from QIODevice::open() as it's unconditionally true. (QIODevice::open() doesn't use the protected virtual pattern.) I'll try and tackle QIODevice in a future commit. [ChangeLog][QtCore][QFileDevice] The open() functions of file-related I/O classes (such as QFile, QSaveFile, QTemporaryFile) can now be marked with the "nodiscard" attribute, in order to prevent a category of bugs where the return value of open() is not checked and the file is then used. In order to avoid warnings in existing code, the marking can be opted in or out, by defining QT_USE_NODISCARD_FILE_OPEN or the QT_NO_USE_NODISCARD_FILE_OPEN macros. By default, Qt will automatically enable nodiscard on these functions starting from Qt 6.10. Change-Id: Ied940e1c0a37344f5200b2c51b05cd1afcb2557d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* wasm: Add auto test for qfileEven Oscar Andersen2024-04-131-2/+2
| | | | | | | | | | | | | | Problems: * mmap of size 0 works, add test in QFSFileEnginePrivate::map to make sure wasm platform behaves as the other platforms * qwe// is a valid filename on wasm, QSKIP test * applicationFilePath does not exist on wasm. * /dev/zero does not exist on wasm, file bug, skip test * blocking pipes do not exist on wasm, QSKIP test * socketpair does not exist on wasm, QSKIP test Change-Id: I1705c543782cbcb92a7ebed2fc2792613524c686 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QSaveFile[win]: Use SetFileInformationByHandle for atomic renameMårten Nordheim2024-04-123-1/+43
| | | | | | | | | | | | | | | With our previous setup we would CloseHandle the file handle and then MoveFileEx the file to the final destination. This opens up the opportunity for other processes to open the file in the meantime and cause the MoveFileEx to fail. With SetFileInformationByHandle we can, without closing the handle, rename the file to the final destination. Fixes: QTBUG-122208 Pick-to: 6.7 Change-Id: Id3c8e0b5703da280c84e466ed88287e99788d077 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLoggingRule: default initialize 'messageType' memberDennis Oberst2024-04-112-7/+4
| | | | | | | | Fixes Axivion(SV70928): Qt-Generic-InitializeAllFieldsInConstructor Task-number: QTBUG-122619 Change-Id: Ida5ed45c6bce30541fb268f7aeb4339eca2f4dbe Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* QProcess: build forkfd as C codeThiago Macieira2024-04-101-0/+3
| | | | | | | | | | | | | | | | | | | | forkfd_qt.cpp was originally created so we could use the Qt atomic classes back when we couldn't rely on C11. We now can, so that primary reason is gone. We only need it now to set NDEBUG, which the Qt build doesn't set by default, and _GNU_SOURCE to match forkfd.c itself (GCC and Clang define it by default in C++ mode because libstdc++ apparently needs that). Amends 993db5a12227b1e4067714ddc626d64a14474a54 and thus avoids a new Clang 18 warning about using VLAs in C++ code: forkfd_linux.c:160:50: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension] Pick-to: 6.7 6.6 Change-Id: I5f663c2f9f4149af84fefffd17bed82d39be4d78 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QStorageInfo/Linux: remove dependency on linux/mount.hThiago Macieira2024-04-031-2/+6
| | | | | | | | | | | | | | | | It was introduced in December 2018, which is apparently too recent for some Linux distributions. So remove the dependency that was there only to give us MS_RDONLY and revert to the old statfs.h / sys/vfs.h flag. We still don't include <sys/vfs.h> because it is absent on some old Android versions. Amends ea6abe583f8534495c3c43e2b6aab95742b102a3. Pick-to: 6.7 Fixes: QTBUG-123932 Change-Id: If1bf59ecbe014b569ba1fffd17c29cc448d16358 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Logging: introduce QInternalMessageLogContext to hold current contextThiago Macieira2024-03-271-2/+3
| | | | | | | | | | | | | | QMessageLogContext is a primitive type that may be extended in the future with more fields (it has been at version 2 since commit 6d166c88220ee09821b65fb2b711fa77a5312971, though that did not extend the struct's size). This introduces a QInternalMessageLogContext which is used in before all our calls to qt_message_output(). Currently there's no difference and no way to tell that the internal version is used. Change-Id: I01ec3c774d9943adb903fffd17b7d5abc0052207 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QStorageInfo: fix use-after-moveMarc Mutz2024-03-251-2/+3
| | | | | | | | | | | | | | | | | | | | | Coverity complained about a use of the moved-from (in the first line of the loop) `info` object in subsequent lines. This specific instance is harmless, because the field being accesssed is a scalar and the move SMFs are the default ones, so the field isn't actually changed when the struct is moved from. Still, to silence Coverity and to guide other attentive readers of the code, take a copy of the field before moving from the struct, and use the copy's value after the move. Amends ddc39eb3a46d699c23d39f0e914978199eb98cc6. Amends 3e330a79ec8d273630660eefae42995018421c0c. Pick-to: 6.7 Coverity-Id: 444199 Change-Id: I26ea8669f27124fb2567b16d803d47ab439f1e41 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QDebug: fix copy-instead-of-move issuesMarc Mutz2024-03-251-12/+12
| | | | | | | | | | | | | | | | | | | | | | Coverity correctly complains that we're copying the QDebug object when calling print*Container() when we could have moved it into the helper. So do move it. Pick-to: 6.7 6.6 6.5 Coverity-Id: 406803 Coverity-Id: 407406 Coverity-Id: 408523 Coverity-Id: 408562 Coverity-Id: 418431 Coverity-Id: 424788 Coverity-Id: 425106 Coverity-Id: 426537 Coverity-Id: 427163 Coverity-Id: 428925 Coverity-Id: 444463 Change-Id: Ic80247f315a09fffe9363577dff1d1c781859304 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Android: don't append slash for content paths under QAFEAssam Boudjelthia2024-03-221-1/+7
| | | | | | | | | | | content URI obtain permissions when selected by the Android file provider, and the Android APIs will treat them as different URIs if a slash is added and thus such paths will be unaccessible the same way. Amends d89c32140a0f9b0bd5de113762c28d7861d4a928. Change-Id: I8107c7d482dee75f4637e13400b8844b3d3ff804 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QFileInfo: checkAttribute should take lambdas by valueAhmad Samir2024-03-212-6/+7
| | | | | | | | So that they are moved. Pick-to: 6.7 6.6 6.5 Change-Id: I3d1767944200962be90d3eb8695c92a766c4c744 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAbstractFileEngine: remove member FileTime and use QFile::FileTimeAhmad Samir2024-03-2115-79/+45
| | | | | | | | | This is probably a remnant from when QAbstractFileEngine was public API since it's been changed to private API, just use QFile::FileTime. Pick-to: 6.7 Change-Id: I60d3d4ff811f95434b81d5ca115f5d43cfff8b15 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileSystemEngine: make factory functions return unique_ptr<QABFE>Ahmad Samir2024-03-2110-39/+40
| | | | | | | | | | | | | | | | This makes the ownership of the returned pointer clearer. It also matches reality, some call sites were already storing the pointer in a unique_ptr. Also shorten the function name to "createLegacyEngine", you have to read its docs anyway to figure out what it does. Drive-by changes: less magic numbers; use sliced(); return nullptr instead of `0`. Change-Id: I637759b4160b28b15adf5f6548de336887338dab Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QAbstractFileEngineIterator: add `bool advance()` virtual methodAhmad Samir2024-03-207-65/+42
| | | | | | | | | | | | | | | | | | | | | | | And remove hasNext/next() methods. This remodels QAFEI to be like QFileSystemIterator. This better fits the logic in the newly added QDirListing class (which uses STL-style iterators). QFSFileEngineIterator: Initialize the internal nativeIterator in the constructor; also replace the advance() private method with an override for the advance() method inherited from the base class. QResourceFileEngineIterator: Override currentFileInfo(), with a QResouces the QFileInfo is created on demand if/when this method is called. This is the backend/private API, and QDirListing is the public API that can be used in a ranged-for to iterate over directory entries. Change-Id: I93eb7bdd64823ac01eea2dcaaa6bcc8ad868b2c4 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QAbstractFileEngine: add a path parameter to beginEntryList()Ahmad Samir2024-03-1711-38/+32
| | | | | | | | | | | | | Change beginEntryList() to take a path parameter, which it passes on to the QAFEIterator constructor; setting the path at construction makes more sense, because typically the path isn't supposed to change during iteration, and this simplifies the code at the call site. Remove setPath(), the last usage in Qt repos was in QtCreator, and that has been ported away from it. Change-Id: I01baa688e0f9b582aacb63d7d98a794276e58034 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAbstractFileEngine: make {begin,end}EntryList() return a unique_ptrAhmad Samir2024-03-178-23/+35
| | | | | | | | Makes ownership clearer. Change-Id: Ibb57ca900ef30b16d48964a977e997ba6705248b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Bootstrap: remove QDirListing/QDirIteratorThiago Macieira2024-03-132-0/+12
| | | | | | | | | | Bootstrapped tools don't usually need to list directories; they should operate on file lists passed to it by the build system instead. This may deserve a QT_FEATURE. Change-Id: I01ec3c774d9943adb903fffd17b7ecfba2702fc5 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Bootstrap: remove QTemporaryFileThiago Macieira2024-03-1310-21/+21
| | | | | | | | | Done by harmonizing the use on the QT_CONFIG(temporaryfile) macro and fixing one test that was missing. We can't remove the older macro because it is marked PBULIC) but we don't need to use it ourselves. Change-Id: I01ec3c774d9943adb903fffd17b7eb4dd1a4e63f Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QProcess/Unix: fix close() on invalid file descriptorThiago Macieira2024-03-121-1/+2
| | | | | | | | | | | | | | | | Commit 90bc0ad41f9937f9cba801b3166635f6f55e0678 ("QProcess/Unix: add failChildProcessModifier()") added this line that set childStartedPipe so that the failChildProcess() callback had something to write to. But we left it set on exit from QProcessPrivate::startDetached(), which caused the QProcess destructor to try and close it. Noticed when debugging the issue for QTBUG-123083. Pick-to: 6.7 6.7.0 Task-number: QTBUG-123083 Change-Id: I6818d78a57394e37857bfffd17bbc41c8400270f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProcess/Unix: fix improper restoration of signal mask and cancel stateThiago Macieira2024-03-121-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By just moving the handling of the child process' desired target directory below the initialization of either the signal mask and PThread cancel state, without that "return". Commit 52ed6af5277100ed5b9a4f4231b94013ce539a2c ("QProcess/Unix: merge some code from startProcess() and startDetached()") introduced QChildProcess and merged the functionality of PThreadCancelGuard into it. But it added that "return;" to the code path failing to opendirfd() the target directory, meaning that the QChildProcess constructor could exit without calling disableThreadCancellations(), but the destructor would still run restoreThreadCancellations() every time the opening failed. And we have tests for that: setNonExistentWorkingDirectory and detachedSetNonExistentWorkingDirectory. For the cancel state, the uninitialized variable we ended up passing to pthread_setcancelstate() was probably harmless, because the cancellation state is almost always active and the variable would have been non-zero. And we don't test pthread cancellation, so we would never notice the problem. But commit bd32c7d7055b436b8c33486a5b5ce1c29db77fd4 ("QProcess/Unix: block all Unix signals between vfork() and exec()") introduced a block of the Unix signals with the same uninitialized variable problem. Unlike the PThread cancellation state, the original signal mask would usually be empty, so the "restoration" would actually mask signals we wanted. And one such important signal is SIGCHLD, used by QProcess/forkfd when *not* using vfork semantics. This meant that tests that had a child process modifier (meaning, they wouldn't use vfork semantics) would end up timing out because we'd never get the SIGCHLD that told us the child had exited. Fixes: QTBUG-123083 Pick-to: 6.7 6.7.0 Change-Id: I1362eb554b97dc012d02eab2dbca90b06728460e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QUrl: Use new comparison helper macrosRym Bouabid2024-03-062-48/+69
| | | | | | | | | | | | | | | | The class had operator==(), operator!=() and operator <() defined as public member functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of these methods and replace them with hidden friends. Use QT_TEST_ALL_EQUALITY_OPS macro in unit-tests. Use new \compares command in the documentation to describe the comparison operators provided by QUrl. Task-number: QTBUG-120303 Change-Id: Ic4fa2335292cc4b75ad2373832c0b89d768f529c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove unnecessary #undef about q{Debug,Info,Warning,Critical,Fatal}Thiago Macieira2024-03-041-7/+0
| | | | | | | | | | | | | | | | | | The ones in qlogging.cpp were copied to it from qglobal.cpp in commit 23688d8942895507f4bc1517dd3c161134f4f9d0. They existed in qglobal.cpp like in qdebug.cpp since the beginning of the public history. The one in qdebug.cpp already made no sense in Qt 4 times, because qdebug.cpp was a documentation-only source (no actual C++ code). The #undefs from qglobal.cpp hadn't been necessary since commit d394ca7f27197cfbfc28eb9a08eb0db261dd9d3d, the global functions qDebug(), qWarning(), qCritical(), etc. were replaced by member functions in QMessageLogger whose names did not match the macros. Pick-to: 6.7 Change-Id: I50e2158aeade4256ad1dfffd17b1c62f23eca4db Reviewed-by: Kai Köhne <kai.koehne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Replace some QString::fromUtf16() with QStringView::toString()Thiago Macieira2024-03-041-1/+1
| | | | | | | | | | | | | | The QStringView counterpart is somewhat faster because it doesn't go through the UTF-16 codec in QUtf16::convertToUnicode(), which tries to detect the BOM. I've included QString::fromWCharArray in this because: a) it's used extensively in Windows code b) wide chars in memory probably don't have BOMs anyway Change-Id: I01ec3c774d9943adb903fffd17b815be4d2ab8ba Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QProcess/Doc: remove the note that about FailedToStart after started()Thiago Macieira2024-03-031-3/+0
| | | | | | | | | | | | | | | | | | It was added in commit 75a2c81b0041df4ca59178cf52d9e5a8815f3524: Handle posix_spawn using exit code 127 to indicate fail-to-start Most posix_spawn implementations are done using fork(), so the only way to report errors afer fork() is via a special exit code. Support for posix_spawn was removed when we dropped QNX 6.5 support in Qt 5.7 (commit 005a8bfbf0022f03dafafcf2b5c438ccf0675a49). Also complements commit d012e953bfb498091c0ea9a83a717a3deffc670f. Pick-to: 6.6 6.7 Change-Id: I76ffba14ece04f24b43efffd17aadead7c30146b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>