summaryrefslogtreecommitdiff
path: root/src/corelib
Commit message (Collapse)AuthorAgeFilesLines
* QPartialOrdering: update docs and change parameter namesDennis Oberst2023-05-172-59/+87
| | | | | | | | | | Let's be more explicit with QPartialOrdering's showcase of its functionality in the docs and define a possible function-declaration. Also change all parameter names to lhs and rhs, respectively. Pick-to: 6.5 6.2 5.15 Change-Id: Ibc5c0b418bff3278e10e415c7f5bfa86227fc066 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QVarLengthArray/QList: make assign() return a reference to *thisMarc Mutz2023-05-174-18/+18
| | | | | | | | | | | | | While std::vector::assign() returns void, std::basic_string::assign() returns std::basic_string&. In Qt, we want to be consistent between {QVLA,QList,QString,QByteArray}::assign(), and returning *this is the more general solution, so do that. Task-number: QTBUG-106196 Task-number: QTBUG-106200 Change-Id: I2689b4af032ab6fb3f8fbcb4d825d5201ea5abeb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QList: re-use the prepend buffer, if any, on assign()Marc Mutz2023-05-171-4/+43
| | | | | | | Task-number: QTBUG-106196 Change-Id: I62d8610529cab528ae1b114d29707133b4fc28dc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QSemaphore: add QDeadlineTimer APIThiago Macieira2023-05-165-48/+64
| | | | | | | | This removes the last use of QtPrivate::convertToMilliseconds(). Change-Id: I6f518d59e63249ddbf43fffd1759fee2e00d36f4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Fix unused variable 'FakeErrnoForThrow' [-Wunused-const-variable]Tor Arne Vestbø2023-05-161-10/+10
| | | | | | | Amends ba05af82d3d8b7cbc6e22f93cbf1e3d1575afefe. Change-Id: I979d43af3e937edd69b75c9138f1b24ebdc8fac3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QModelIndex: improve qHashThiago Macieira2023-05-161-1/+7
| | | | | | | | | | | QModelIndex's qHash is really bad. It was retained from Qt 5, but ends up producing poor results in large hashes. This can't be fixed in Qt 6. Task-number: QTBUG-113613 Change-Id: I5f7f427ded124479baa6fffd175f7810e1dc2580 Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* QArrayDataPointer: add a C++20 ranges-style optional projection to assign()Marc Mutz2023-05-161-4/+6
| | | | | | | | | | | | This will be useful for implementing QString::assign(), which otherwise has the problem that it's d_ptr is based on char16_t, but it's assign() is supposed to be able to deal with iterators whose value_type returns QChar. Task-number: QTBUG-106198 Change-Id: I87882bf749b4e21b7b32391167962d3e6bae9983 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QList: add STL-style assign()Dennis Oberst2023-05-163-2/+118
| | | | | | | | | | | | | | | Implemented assign() methods for QList to align with the criteria of std::vector, addressing the previously missing functionality. Reference: https://en.cppreference.com/w/cpp/container/vector/assign [ChangeLog][QtCore][QList] Added assign(). Fixes: QTBUG-106196 Change-Id: I5df8689c020dafde68d2cd7d09c769744fa8f137 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make QGenericRunnable a private nested class of QRunnableMarc Mutz2023-05-161-1/+2
| | | | | | | | | We don't intend to make QGenericRunnable public API, so prevent people from using it outside QRunnable::create(). Change-Id: I49f182463ca307aaf6370adfa43bae14b4ce0df8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* q20chrono: Fix feature test macro checkFabian Kosmale2023-05-161-2/+2
| | | | | | | | | | | | | | | | | While the comment behind the else already had the correct value, the actual check and the comment behind the endif had the wrong one. This would cause build /headers clean check failures when using older compilers in C++20/2a mode. Also, remove the check for __cplusplus: A sufficiently high enough value of __cpp_lib_chrono already implies __cplusplus > 201703L; the only thing the check did was to hide the issue on more modern compilers. Fixes compilation with e.g. gcc 9.3. Amends bde5eeecaf35f7b7a94b7878289a8e7fcd057afa Change-Id: I74e761d9dc4048e9abf9cea9ea7e63260ea1111e Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QHash: suppress GCC 12 & 13 warning that QHash could overflowThiago Macieira2023-05-151-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | It can't unless you really have so many elements that it should overflow. When growing, we call bucketsForCapacity(), which won't overflow; when copying/detaching, we allocate the exact same amount of memory that we've previously allocated, so that has to be good too. There was nothing wrong with the previous code. The warning was showing how the compiler had detected a possible overflow and caused a call to operator new(-1) to force std::bad_alloc to be thrown. Disabling the warning did not work in LTO mode. So we mimic it: Q_CHECK_PTR will call qBadAlloc() for us if exceptions are enabled, or qt_check_pointer() if not but assertions are (if neither are, then we have no means of reporting the error, so let's just assume that it can't happen). In function ‘allocateSpans’, inlined from ‘__ct ’ at qhash.h:581:48, inlined from ‘detached’ at qhash.h:596:20, [...] qhash.h:551:19: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=] Commit 1d167b515ef81ba71f3f47863e66d36ed6d06c1c is the likely source of this warning. Fixes: QTBUG-113335 Pick-to: 6.5 Change-Id: Ieab617d69f3b4b54ab30fffd175bb8d36228209c Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* QHash: centralize the span allocationThiago Macieira2023-05-151-9/+17
| | | | | | | | | Deduplicates code and will allow me to insert some magic. Pick-to: 6.5 Task-number: QTBUG-113335 Change-Id: Ieab617d69f3b4b54ab30fffd175bb4a2af610ff8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QProcess/Unix: enable setChildProcessModifier for startDetachedThiago Macieira2023-05-151-38/+29
| | | | | | | | | | | | | | Do this by making the actual child-execution code common between startProcess() and startDetached(). It does mean we've moved the chdir() operation from the child to the grandchild process, though. [ChangeLog][QtCore][QProcess] The modifier function set with setChildProcessModifier() will now also be executed when the process is started with startDetached(). Change-Id: Icfe44ecf285a480fafe4fffd174d9aa57dd7dfff Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: improve the error message if the child modifier throwsThiago Macieira2023-05-151-2/+6
| | | | | | | | Functionality added for 6.5, but after translatable string freeze. Change-Id: Icfe44ecf285a480fafe4fffd174d984c5349e0cb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: protect against stack unwinding in the child process stubThiago Macieira2023-05-152-4/+58
| | | | | | | | | | | | | | | | | | | | | | There are two types of stack unwinding that can happen on Unix systems: C++ exceptions and PThread cancellations (on some systems, like Linux, PThread cancellations can be caught in catch(...) statements). We call a variety of PThread cancellation functions from inside the child stub, like close(). To avoid problems, we disable PThread cancellations completely before fork() or vfork(). The C++ exception case is simpler, because we can be sure of catching them with the catch (...) statement and simply transform them into an error message. This is also testable, which the PThread cancellation isn't. The error message isn't ideal because we're string-frozen. I'll improve it for 6.6. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d97a475c93ff1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QEventDispatcher/WASM: fix a lambda nameAhmad Samir2023-05-151-3/+3
| | | | | | | | | It's returning milliseconds not nanoseconds. Change-Id: I7dbc3f4043694b6ddf87c6ad9e4d20d3a9af0fd1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
* Darwin: Use direct runtime interface to manage autorelease poolsTor Arne Vestbø2023-05-151-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | The Objective-C runtime supports autorelease pools via a language specific ABI supplement, akin to the “Itanium” generic ABI for C++. https://clang.llvm.org/docs/AutomaticReferenceCounting.html#runtime-support These interfaces are used by NSAutoreleasePool internally, as well as inserted by the compiler when using the @autoreleasepool syntax in Objective-C code. We have our own wrapper, QMacAutoReleasePool, which allows us to set up pools in C++ code as well. We now use these lower level interfaces in the implementation, instead of NSAutoreleasePool, as this reduces overhead due to not needing to allocate and destroy a NSAutoreleasePool. This also opens up the possibility of using Automatic Reference Counting (ARC) in Qt down the road, as explicit NSAutoreleasePool usage is forbidden in that mode (while @autoreleasepool is not, and uses the runtime ABI internally as before). Change-Id: I06fdb4a24ae4972820f866e0a129a1b355bc8a6b Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Darwin: Disable QMacAutoReleasePool tracker unless explicitly enabledTor Arne Vestbø2023-05-151-0/+4
| | | | | | | | | | | | There's a few orders of magnitude of overhead using QMacAutoReleasePool with the tracker enabled, so disable it even for debug builds, unless explicit auto release pool debugging has been enabled via the environment variable QT_DARWIN_DEBUG_AUTORELEASEPOOLS. Pick-to: 6.5 Change-Id: Iec00c703eb21e1914903954cfd02f9f6b1ec2a1f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Darwin: Disable QMacAutoReleasePool tracker in release buildsTor Arne Vestbø2023-05-151-2/+5
| | | | | | | | | | | It adds overhead that is noticeable, especially in tight loops that rely on an auto-release pool. For example, this improves the QLocale date to string transformations an order of a magnitude. Task-number: QTBUG-104785 Pick-to: 6.5 Change-Id: I246dc4e114bd75dd4e3e9e42b061c4c20c94d522 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Darwin: Remove QMacAutoReleasePool heap allocation detectionTor Arne Vestbø2023-05-151-47/+3
| | | | | | | | | | This is handled by the Objective-C runtime nowadays, where it will abort if the situation is detected, with the option to break on objc_autoreleasePoolInvalid to debug the situation. Pick-to: 6.5 Change-Id: Idf2c4aacc77e41a3deebf270303f4f13cfb0819b Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Fix case-sensitivity of exponent separator check in Cyrillic fall-backEdward Welbourne2023-05-151-1/+2
| | | | | | | | | | | | | | | | | When matching the locale's correct exponent separator, QLocale was doing a case-insensitive match; but the Cyrillic fall-back was matching case-sensitively, so failed to catch the case of lower-case e and its Cyrillic equivalent, when used in a Cyrillic font in place of the upper-case form of the other, where that's the locale's official separator. So make this comparison case-insensitive. Added some test-cases for the lower-case exponential separator. Pick-to: 6.5 Fixes: QTBUG-113443 Change-Id: I18e22d7b3451fbb61e87d5b93661eadff3c7356e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
* Convert remaining QT_NO_XMLSTREAM* to use feature systemEdward Welbourne2023-05-158-46/+48
| | | | | | | | | | | | | | | | Replace the check in qxmlstream.h with a QT_REQUIRE_CONFIG since the code that includes this header does no checking, whether on the define or the feature, so is better off getting told about the missing feature at the point of include than complaining about an undefined type despite its header being overtly included. For the rest, just do the usual transformation to QT_CONFIG(), flipping the ones that were #ifdef rather than #ifndef, so the condition is positive. Shifted a couple of open-braces of classes to the next line, where they belong, in the process. Change-Id: If9c496082f0489b0f9f4070364cbf840e603fce1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Clean up phrasing of --help-all and other help optionsEdward Welbourne2023-05-151-5/+10
| | | | | | | | | | | | | | | | | | The options included by --help-all, although they are "specific to Qt", are "specific" to all Qt applications, so - in the present context, of QCommandLineParser - not specific at all. It's the options described by -h that are specific, to the present command; the Qt options are generic (in the present context). So rework the help string for --help-all itself and the documentation of the function. It had, in any case, an overly-complex first line, that descended into too much detail. Updated test to match. Pick-to: 6.5 Task-number: QTBUG-111228 Change-Id: I06da0af41be60e6e1b7616984001ddb9ca33aad6 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* Don't create a QTimeZonePrivate object for an unsupported time zone IDAndreas Buhr2023-05-151-2/+7
| | | | | | | | | | | | The QTzTimeZoneCache created one cache entry for every time zone which was looked up, even if the code was invalid. This uses some memory for each time zone code queried and thus allows DOS attacks if user supplied time zone codes are parsed. This patch prevents the creation of QTimeZonePrivate objects for invalid time zone IDs. Change-Id: I22007f6681bea54fa08639f4f786e1a49d10f920 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Include all available IANA DB zones for the TZ backendEdward Welbourne2023-05-151-2/+34
| | | | | | | | | | | | | Previously, QTzTimeZonePrivate::availableTimeZoneIds() only reported the zones listed in the zone.tab file, which maps territories to zones. It thus omitted several zones that are provided by the IANA DB, but not the primary zones for any territory. This meant that it was possible to pass a zone name to the constructor successfully, despite isTimeZoneIdAvailable() claiming it isn't available. Pick-to: 6.5 Change-Id: I9e4eb7f4cfe578204951b995f0ad9ffd7eed5f9c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Replace mentions of deprecated macroTopi Reinio2023-05-151-1/+1
| | | | | | | | | Q_ENUMS() is deprecated in favor of Q_ENUM(). Pick-to: 6.5 Task-number: QTBUG-113229 Change-Id: I29cc23c87b1d6e8eeb49dd1d3ddaf4ca7d2cf8c2 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Make QByteArray(qsizetype size, Qt::Initialization) doc publicTopi Reinio2023-05-151-2/+0
| | | | | | | | | | The constructor that doesn't explicitly initialize the content of the array can be useful in some cases. Pick-to: 6.5 Fixes: QTBUG-111582 Change-Id: Icc4bd753f1944a91be70316a7303bb822f79d472 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Unix: use open() + fchdir() to change directoriesThiago Macieira2023-05-152-19/+46
| | | | | | | | | | This means we have more system calls (2 more in the parent), but we can now detect non-existent or inaccessible directories before fork(). Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d1003581bff59 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: use pid_t for the pidThiago Macieira2023-05-152-6/+4
| | | | | | | | | | | | | | | | | | Qt 5 and earlier versions used to share this member with Windows, where we needed to store a pointer. We had the Q_PID public type, which was removed in commit b73d5a0511bed8c3ccc504e74c52a61d4d3749b4 (6.0). That commit made the QProcess::processId() public API use qint64, which is fine. But we don't need to store more bits than the OS actually requires. This further reduces QProcessPrivate's size to 688 bytes on 64-bit Unix, with 5 bytes of tail padding. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d3fa9345872c0 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Revert commit "don't ever force fork() instead of forkfd()"Thiago Macieira2023-05-152-9/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit d6bf71123d3ef073f25610345cb5dc920e4fb783 and the docs from commit 82b75570f099911076ad0e144927862e8e359fbd ("QProcess/Linux: fix file descriptor leak in case of failed child start"). Despite the title of the commit being reverted, the actual consequence is slightly different: we always use the forkfd() function, but we change whether we force the use of the fork() library function by use of the FFD_USE_FORK flag. Commit 97645478de3ceffce11f58eab140c4c775e48be5 (5.15) first added the FFD_USE_FORK flag with a hack to detect whether the setupChild() virtual might have been overwritten. A configure-time feature to force the flag was added in commit 2ed99ff5ca338ac02f71c347b1449d4662e6c221 (6.0). Before the 6.0 release, commit d6bf71123d3ef073f25610345cb5dc920e4fb783 removed the conditional use of FFD_USE_FORK, with the changelog message saying "pthread_atfork() callbacks are consistently not invoked". We've also since added vfork()-like behavior. We tried it for Qt 5.15 and reverted shortly afterwards because we had got the memory semantics wrong. Commit e1a787a76ed462e4ed49db78a40c6d7e272182d7 (6.5) finally got it right, for Linux, which revealed another set of problems with functions used in the child process modifier. Therefore, we're going to make vfork() and clone() usage opt-in if the child process modifier is active. This commit is the first part: disabling their use by default. The flag to opt in will come in Qt 6.6. [ChangeLog][QtCore][QProcess] Reverted a change from Qt 6.0 that made the childProcessModifier() callback be run in a child created by means other than a real fork() library call, a situation in which certain other library functions would be unusable, unreliable, or cause deadlocks. A flag to opt in to the solution with better performance will be added to Qt 6.6. Task-number: QTBUG-104493 Fixes: QTBUG-111243 Fixes: QTBUG-111964 Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d3e66843e5a29 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProcessPrivate: repack and reorganize the membersThiago Macieira2023-05-153-36/+34
| | | | | | | | | | | | | | | | | Reduce the number of #ifdef blocks and use quint8 for the enums that don't need more than 8 bits anyway (none of them do). Plus move the std::function callback to an indirect block, as most users of QProcess won't set them and this type is 4 pointers with libstdc++ and libc++. After this, QProcessPrivate on 64-bit Unix is 688 bytes, of which: - 392 bytes from QIODevicePrivate - 295 bytes of own data - 3x56 bytes per Channel (which have 5 bytes of tail padding each) - 1 byte of tail padding and no middle padding Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d188a0821d060 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcessPrivate: remove the member variable "crashed"Thiago Macieira2023-05-134-9/+11
| | | | | | | | | | | | | It was only used to later set exitStatus = CrashExit, so simply do it early. Drive-by removal of a magic numeric literal in the middle of the source code. It's still magic, but at least we avoid accidentally making typos. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d4176a5d87641 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid littering CMake logs with QTP0002 warningsAlexey Edelev2023-05-121-8/+11
| | | | | | | | | | | | | | | It doesn't make any sense to setup and get policy when we build either Qt or standalone tests, since the value will be ignored anyway. So skip the policy setup for Qt builds to avoid littering the CMake logs with QTP0002 warnings. Amends c4debab927671de802d377f31e4fff4136da9104 Change-Id: Iacae8f9ecbb6c9da2f3af77b2016454c8d4194e6 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Check if next property in the list is not empty before adding a commaAlexey Edelev2023-05-121-0/+3
| | | | | | | | | | | | Property merging genex only checks if previous value is not empty, but doesn't check if an actual value that we concatenate is not empty too. Add the check to make sure we don't have trailing comma in the json lists. Fixes: QTBUG-112885 Pick-to: 6.5 Change-Id: I1a5265ddf1b12f763650daf3c6e3538ed52a1674 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Enable [[noreturn]] attribute for non-MSVC compilers on WindowsPeter Varga2023-05-123-6/+6
| | | | | | | | | | | | | | Avoids -Wsometimes-uninitialized warnings with clang-cl. Also do not allow to return qt_message_fatal() if built with other compiler than MSVC. Amends 97b32fa0b661c5dd89d525122427496132abb54a Fixes: QTBUG-113351 Change-Id: I9ce87057e764af1e25de93388ae983891df66d2e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSlotObjectBase: move the `which` parameter to the 4th positionThiago Macieira2023-05-114-5/+39
| | | | | | | | | | | | | | | | | | | This places the first through third parameters on the exact positions that they will be used to perform the operations in the switch, saving the compiler from generating a few instructions to move data around. All ABIs Qt supports that pass any function parameters in registers at all pass at least 4. We keep the return type as void (instead of returning bool, for the Compare case) so the compiler can apply tail-call optimizations for those two typical cases. PMF case: https://gcc.godbolt.org/z/9oP5boKfj Function case: https://gcc.godbolt.org/z/e9vEzd5dj Functor case: https://gcc.godbolt.org/z/s8Ejjra7P Change-Id: I3e3bfef633af4130a03afffd175d3e3009c56323 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* IPC: QNativeIpcKey: fix big-endian buildsThiago Macieira2023-05-111-7/+17
| | | | | | | | | | | | | We weren't using the LSB in big-endian builds because the bitfield was in the wrong order: it was either using the MSB (in 32-bit builds) or something in the middle for 64-bit. So use quintptr in the bitfield to ensure proper sizing and correct the order. Additionally, we now store the d "pointer" as a quintptr, so as to avoid storing the actual pointer to QNativeIpcKeyPrivate with the LSB set. Change-Id: Idd5e1bb52be047d7b4fffffd17506adb77d52805 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QLatin1StringView: un-inline Latin1-UTF8 compare_helperThiago Macieira2023-05-113-9/+15
| | | | | | | | | | | | | | | | | | | Commit c630b231ecd674b80a554bf40b37086b64c73f6a ("Untangle QLatin1StringView from qstring.{h,cpp}") moved QLatin1StringView from qstring.h, causing compilations that included qlatin1stringview.h but not qstring.h to produce a warning. By un-inlining, we get an improved comparison functionality without memory allocation too. So win-win. qlatin1stringview.h:325:23: warning: inline function ‘static int QLatin1String::compare_helper(const QLatin1StringView&, const char*)’ used but never defined This is BC because the actual function that used to be inline continues to be so, and the old implementation is fine, albeit slower. Change-Id: Ieab617d69f3b4b54ab30fffd175c4e11d4a3b6dd Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QReadWriteLock: inline the constructor and destructorThiago Macieira2023-05-112-5/+22
| | | | | Change-Id: Ieab617d69f3b4b54ab30fffd175b2500dd860431 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QMutex: add QDeadlineTimer-based tryLocksThiago Macieira2023-05-116-33/+106
| | | | | | | | | | | | | | This simplifies the code greatly, because we don't need to use QtPrivate::convertToMilliseconds any more, as QDeadlineTimer has nanosecond precision. Internally it becomes simpler too because lockInternal was already using QDeadlineTimer. I just had to use the parameter instead and update the two non-futex implementations to take it again. This may even be fixing a mistake in case sem_timedwait(2) got interrupted. Change-Id: I6f518d59e63249ddbf43fffd1759fed9f50b3606 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QReadWriteLock: add tryLockForXxx overloads taking QDeadlineTimerThiago Macieira2023-05-113-48/+98
| | | | | | | | | | | | | | This propagates inside the internals, ending up in wait_until calls in the internal std::condition_variable. For systems with proper support for monotonic waiting (Linux, FreeBSD), this should improve performance. We could even remove the hasExpired() check and pass a time point in the past too. Right now, there's a minor performance drawback for tryLockForXxxx(), because we will make at least two system calls to get the time. Change-Id: I6f518d59e63249ddbf43fffd1759fc5b2e40256a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QReadWriteLock: inline the lockForXxx functionsThiago Macieira2023-05-113-8/+20
| | | | | | | | We can now do that because tryLockForXxxx(-1) is fast for the uncontended case too. Change-Id: I3d728c4197df49169066fffd1756ddd06caf7b52 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QReadWriteLock: remove the untimed tryLockForXxxx functionsThiago Macieira2023-05-113-44/+17
| | | | | | | | | | They're unnecessary now because the timed function is fast enough. Note: the default argument will move to the QDeadlineTimer functions before the Qt 6.6 release. Change-Id: I3d728c4197df49169066fffd1756ddc0e4f796d3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QReadWriteLock: force the loop to exist in a separate functionThiago Macieira2023-05-111-2/+15
| | | | | | | | | | | This allows the fast, uncontended case to exist in a function that does much less work and therefore needs to save less state in its prologue. This is interesting too for LTO because the compiler can then inline the fast, uncontended path where the locks were used. Pick-to: 6.5 Change-Id: I3d728c4197df49169066fffd1756dc04d8a5f04a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QReadWriteLock: remove the private function from the symbol tableThiago Macieira2023-05-115-42/+57
| | | | | | | | | | Just move it to the private class. This also allows this function to get inlined in QWaitCondition::wait(). Pick-to: 6.5 Change-Id: I6f518d59e63249ddbf43fffd1759fc99c28c7ca8 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix QMetaObject::invokeMethod for free functions and std::bindVolker Hilsheimer2023-05-112-19/+7
| | | | | | | | | | | | | | | | | | | | Amends 3bf5b5f8944dd417530b09dd6f1cd568717c8cc1, after which free functions and std::bind could no longer be used as callables in QMetaMethod::invokeMethod. For free functions to work we need to decay to function pointers when choosing what type QtPrivate::Callable aliases. And std::bind has operator() overloads and the return type cannot be deduced. So simplify the definition of the ZeroArgFunctor - we know the function prototype if we know the return type. Add testcase for calling std::bind and free function, and remove the now unneeded helpers for functor argument and return type deduction. Change-Id: I54aac5cb6d660267e6b2f5ab05d583e8826cdf9a Reviewed-by: Zoltan Gera <zoltan.gera@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix QTimeZone::offsetData() for the case without transitionsEdward Welbourne2023-05-111-7/+10
| | | | | | | | | | | | | | | | | | | | | | A zone without transitions, such as any UTC-based one, would previously return invalid data for the offset data at a given time. The method was documented to be "the equivalent of calling offsetFromUtc(), abbreviation(), etc" but these methods do return sensible data for a zone with no transitions. Furthermore, the backend data() method on which it depends is implemented by all backends, including the UTC one, with no transitions. Fix offsetData() to also return data when no transitions are available. Improve docs. Adapt the checkOffset() test to test offsetData() as well as the various functions to get parts of it. In the process, change that test to use a QTimeZone row instead of its name as a QByteArray, so that we can also have rows for lightweight time representations. Change-Id: I241ecf02a26a228cca972bca5e2db687fe41feb4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QRunnable: fix Coverity dead-code warnings in create()Marc Mutz2023-05-111-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | Coverity complained about the call to warnNullCallable() being dead code for most instantiations of the create() function template. It's right, of course, even though warning in a template that clearly has instantations where it's not dead code isn't exactly helpful. Nonetheless, take the opportinity to avoid the dead code warning at the expense of a bit or un-DRY-ing: - because we now use them more than once, cache the result of is_*function_* predicates in constexpr variables - then scope the is_null variable such that its use is not subject to dead-code removal anymore (at instantiation time; it may still be removed by the optimizer) As drive-bys, add a comment about the reinterpret_cast, and make the custom template predicates variable- instead of class templates. Coverity-Id: 407640 Change-Id: I272223042c2aae9d814e82c466e1d29e1c42bfa1 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QGenericRunnable: remove common prefix from nested classesMarc Mutz2023-05-111-12/+11
| | | | | | | | Helps keep the code fit into line length limitations. Change-Id: I2e861c6f0a991cc36991572c4386040b8e11ca40 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move QGenericRunnableHelper info QGenericRunnableMarc Mutz2023-05-111-7/+6
| | | | | | | | | Because we can, and it prevents all the machinery from being exported by the Q_CORE_EXPORT on QRunnable. Change-Id: I80e0690956bff612f2048eefb2b64bc198835f1f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>