summaryrefslogtreecommitdiffstats
path: root/src/corelib
Commit message (Collapse)AuthorAgeFilesLines
* QAbstractItemModel: Fix Qt::TextAlignmentRole when metatype is uintJonas Kvinge2022-05-221-4/+8
| | | | | | | | | | | When combining text alignment flags, it no longer works since the metatype for example QVariant(Qt::AlignRight | Qt::AlignVCenter) is uint, not int. Fixes: QTBUG-103576 Pick-to: 6.2 6.3 Change-Id: If0291b99606787081c4bc26fd00431f8a17a61a2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QMetaType: disable conversion from smart pointer<const QObject>Giuseppe D'Angelo2022-05-211-1/+1
| | | | | | | | | | | | | | | | | | | | | QMetaType can register a converter from a smart pointer class to QObject *. The code tries to do so even if the smart pointer is actually holding a pointer to a _const_ QObject (e.g. shared_ptr<const QObject>), causing a compile error: ../src/qt5/qtbase/build/include/QtCore/../../../src/corelib/kernel/qmetatype.h:1208:32: error: invalid conversion from ‘const QObject*’ to ‘QObject*’ [-fpermissive] 1208 | return p.operator->(); | ~~~~~~~~~~~~^~ | | | const QObject* Disable the conversion if indeed the source is const qualified. Change-Id: I9e9bc5992f74131e5cfd6ece9b83d4f26d370e92 Fixes: QTBUG-103741 Pick-to: 6.2 6.3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Make all loads of QAtomicPointer QObjectPrivate::threadData explicitMarc Mutz2022-05-203-5/+5
| | | | | | | | | | | Replace implicit conversions from QAtomicPointer<T> → T* with the equivalent, but explicit, loadAcquire(). This is in preparation of deprecating the implicit QAtomic<T> ↔ T conversions. Change-Id: I6c8476a705c3996ef724dd63b58d9526d1a39af7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize reads from QObjectPrivate::threadDataMarc Mutz2022-05-202-5/+5
| | | | | | | | | | | | | The implicit conversion operator from QAtomicPointer<T> → T* performs a loadAcquire(). In the cases of this patch, we're only comparing pointer values to check whether QObject thread affinities are compatible, so relaxed loads suffice. Pick-to: 6.3 Change-Id: If19124778b4770d86baeaeb3c91214e47881b288 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* macOS: Try to get SIP configuration via private syscall if possibleTor Arne Vestbø2022-05-201-4/+15
| | | | | | | | | | The SIP configuration is not available through the NVRAM in all cases, so we try to get it via the private syscall first, if we can, and then skip the warning if we don't find it in NVRAM. Pick-to: 6.2 6.3 Change-Id: I0866d06c329a3ac70bb1f23732d10aab13a4f9c1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Move remaining time_t code from qdatetime.cpp to QLocalTimeEdward Welbourne2022-05-204-338/+338
| | | | | | | | | | What remains is all tangled together, but is now at least decoupled from the rest of qdatetime.cpp, so moving it out makes that file easier to read. Task-number: QTBUG-95993 Change-Id: I3fba15aea59b3c8b4cbc6bf1cb03de96d68db0ce Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Split qtLocalTime out into a new QLocalTime namespaceEdward Welbourne2022-05-205-77/+160
| | | | | | | | | | | | | | | ... in new qlocaltime* files, now that it's decoupled enough from the internals of QDateTime for this to be possible. Part of the consolidation of time_t code in one place. Move assorted constants from qdatetime.cpp to a private namespace in qdatetimeprivate_p.h to be shared between q*time.cpp hereafter (fixing an out of date comment in the process - julianDayFromDate() is long gone). Task-number: QTBUG-95993 Change-Id: I03d97e959118041f9d86b8bb2e738599bc0b17e1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace qt_mktime(), avoiding out-parameters and conversionsEdward Welbourne2022-05-201-115/+131
| | | | | | | | | | | | | | | | | | | Since qt_mktime() took QDate and QTime in/out parameters, its callers had to convert the milliseconds they had to that form and back again after. Since it combined optional look-up of zone abbreviation with determination of offset and DST-ness (both ignore when the abbreviation was asked for) it made sense to split it in two. Each takes the millis and whatever knowledge we have of DST. One returns tha abbreviation; the other returns a QDTP::ZoneState for the caller that'll be returning that. Outside the system zone, when we have to fall back to a kludge, their callers can now use the Julian Day number change for its fake date to directly adjust the millis there and back (effectively inlining former conversions to-and-from date and time representation, but optimising out some of the work). Change-Id: I7aa4583171f77fc0f4aa80c8f564e76995ca69d2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Eliminate the msecsToTime() overload with out-parametersEdward Welbourne2022-05-201-26/+12
| | | | | | | | | | Now that I've disposed of the callers that were or might be passing null pointers for the out-parameters, getDateTime() can inline its computation and the two other callers can use msecsTo{Date,Time} until I eliminate the need for that. Change-Id: Ia9169779cf03189fc7fd5271044d1ec90089fa03 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Refactor QDateTimePrivate::*MSecsToEpochMSecs()Edward Welbourne2022-05-202-154/+148
| | | | | | | | | | | | | | | | | | | | Aside from one client that wanted the zone abbreviation for a given local time (and could supply a DST-ness hint), the callers actually want to know the offset from UTC, DST-ness and any correction needed to the local time to dig it out of a spring-forward. Mediating all of that via a QDate, a QTime and a returned UTC seconds since the epoch was not making our lives any easier. Split the local-time function into one to get the abbreviation and another to determine the data we actually need. The zone version only needs the latter. Two functions with hairy signatures replete with in/out parameters are replaced with three, with no in/out parameters. Adapt all callers of the old functions to use the new, simplifying them in the process. Inline some conversions between date+time and msecs in the process. Change-Id: Ice60b615121a99111ed882734785fa3c777e191c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Refactor qt_localtime()Edward Welbourne2022-05-201-85/+87
| | | | | | | | | | | Break out the part that calls the appropriate platform variant, so that the logic of what we do with the result of that isn't tangled up with the #if-ery. Rework the remainder to return a struct type that packages the data we need, to get rid of the three out-parameter pointers. Change-Id: Ibba6f8de0954fab3fddf9e95adc18ef85e45ff72 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime::setMSecsSinceEpoch(): push more work into a helper functionEdward Welbourne2022-05-202-67/+84
| | | | | | | | | | | | | | | | | | | Formerly, setMSecsSinceEpoch() passed a QDate and a QTime to epochMSecsToLocalTime() as in/out parameters, then obtained what it actually wants, a count of milliseconds, from their modified values and computed an offset from that. Pass the epoch milliseconds from which the QDate and QTime were derived in place of them and return the local milliseconds, offset and DST status back in a structure, rather than via pointer parameters. This prepares the way for pushing one step further, back into qt_localtime(), so that we can simply get the count of milliseconds, along with DST flag and offset from UTC, without going via QDate and QTime (except in the kludge that copes with times outside the time_t range; and even that can be short-cut somewhat). Change-Id: I37ebb1efb355e81e1a116d03cbd52f9bb4a1f114 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix wrong QDateTime::isValid() to use the right QFlags methodEdward Welbourne2022-05-201-1/+1
| | | | | | | | | | It's documented to return true "if both the date and the time are valid and they are valid in the current Qt::TimeSpec" but it was using testAnyFlag() so would have returned true if any one of the three conditions was met, rather than only if all three are met. Change-Id: I91746224009d820abaffb541d8f6d6b13142849b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify msecsToTime() and two callers by using QRoundingDownEdward Welbourne2022-05-201-24/+19
| | | | | | | | | | | | | The formerly cumbersome arithmetic, to adjust for division rounding towards zero rather than down, is so much simpler this way. Break out the conversion for only date and for only time, for the sake of (for now) two callers that only need one; and inline QRoundingDown::qMod() to save repeating the qDiv() call. Include the mapping from millis to raw Julian Day as a separate function, as I'll be using it shortly. Change-Id: I0ee74ea68421a347ed618fa34142bd034844351e Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CMake: Ensure creation of a unique iOS bundle identifierAlexandru Croitor2022-05-201-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apple ties iOS application bundle identifiers to Apple accounts. When building against the device SDK, the bundle identifier must be unique, so that Xcode can register the id with the used developer account and create an appropriate provisioning profile for the used device. If it's not unique (was previously used on a machine with a different developer account), in the best case you get an error explaining that. In the worst case you get an error about automatic signing not being enabled (at least on the command line). When building an Xcode project for the first time on a fresh machine, the organization bundle identifier prefix might not be set. Opening a Qt example project on such a machine might result in generating the same bundle identifier, leading to the error described above. Warn project builders that they should either specify a prefix or an entire unique identifier. To ensure building still works in such a case, try to hash the team id if it is present and add it as an infix to the auto-generated bundle identifier. Note that simulator builds are not affected by id uniqueness because apps deployed to the simulator do not require a provisioning profile from Apple. Amends 4d838dae5a821e9e5f013ba1d5a494ece1b5180e [ChangeLog][iOS][CMake] The build system tries to create a unique bundle identifier based on the team id if no organization prefix can be retrieved from Xcode preferences. Pick-to: 6.2 6.3 Task-number: QTBUG-95838 Change-Id: I6ad10076751acf43064330a6e53d6c4e973ec362 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* CMake: Improve iOS bundle identifier handlingAlexandru Croitor2022-05-201-24/+66
| | | | | | | | | | | | | | | | | | | | | | | | Developers could use two different CMake properties / variables to specify the bundle identifier of an application. One would be written into the Info.plist file and the other into the Xcode project as a project property. The previous implementation forced developers to set both of them to the same value to have consistency in the project. This is not nice behavior. The new logic allows setting only one of the two, which will then be reused for the one left unspecified. This is more user friendly. Finally the bundle identifier prefix was never escaped, which could cause issues during code signing if it had invalid characters. Now we escape the prefix to ensure the whole identifier is valid. Amends 4d838dae5a821e9e5f013ba1d5a494ece1b5180e Pick-to: 6.2 6.3 Task-number: QTBUG-95838 Change-Id: I1448bd643893751c281cc0ea41c763d1bd03360e Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Use the PRODUCT_NAME for the iOS display name like qmakeAlexandru Croitor2022-05-201-0/+11
| | | | | | | | | | | | | | | | | | | This ensures that the Xcode 'Display name' input under ${target} -> General -> Identity -> Display name is not empty. Because adding ${PRODUCT_NAME} directly in the Info.plist.in template will cause CMake to evaluate it as variable expansion, work around the issue by putting the dollar sign into a separate cache variable that after evaluation will result in ${PRODUCT_NAME} being in the file verbatim, so that Xcode evaluate it at build time. Amends 4d838dae5a821e9e5f013ba1d5a494ece1b5180e Pick-to: 6.2 6.3 Task-number: QTBUG-95838 Change-Id: I2d1090cc8e84b32442f7daca2d4ce5e3ad413c68 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* CMake: Pick first non-free team id for iOS Xcode projectsAlexandru Croitor2022-05-201-20/+83
| | | | | | | | | | | | | | | | | | | Previously we picked the first reported team id as found in the Xcode settings file. Now we pick the first non-free team id if there is one, otherwise we pick the first free one. This aligns with qmake behavior. Using a non-free team id usually leads to fewer issues with automatic code-signing. [ChangeLog][iOS][CMake] A non-free Xcode team id is now preferred for project signing. Pick-to: 6.2 6.3 Fixes: QTBUG-96341 Change-Id: I58618fe5c6ca04184812e9bf955a9cb0b3842447 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Set iOS default code style signing to AutomaticAlexandru Croitor2022-05-201-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As far as I can see, the default is already 'Automatic' when it is not specified, but it does improve some xcodebuild error messages in certain edge cases if the option is specified explicitly. Note that setting the style to Automatic will not suffice in order to build the project from the command line with xcodebuild, if there is no existing provisioning profile for the project in ~/Library/MobileDevice/Provisioning Profiles You either need to build it once via the Xcode GUI, or you need to call xcodebuild -allowProvisioningUpdates which will try to create / download a provisioning profile from Apple's server. This implies that Xcode must have been launched at least once, and configured with a valid Apple developer account, including a free account. qmake already generates a Makefile that calls xcodebuild -allowProvisioningUpdates. CMake doesn't have a Makefile wrapper, so calling cmake --build . will call xcodebuild directly, which again means users need to pass -allowProvisioningUpdates explicitly. It does not look like CMake intends to call it automatically any time soon, see https://gitlab.kitware.com/cmake/cmake/-/issues/22615 We intend to teach Qt Creator to add the -allowProvisioningUpdate option when building a project using CMake. The code sign style will not be set if the target XCODE_ATTRIBUTE_CODE_SIGN_STYLE property or the CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_STYLE variable has a value. There's also an opt-out variable called QT_NO_SET_XCODE_CODE_SIGN_STYLE Pick-to: 6.2 6.3 Fixes: QTBUG-96347 Change-Id: If65ccb8a0393ff6d80e6caea3b8003fc59a8a62a Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Set default xcode device family to iPhone and iPadAlexandru Croitor2022-05-201-0/+16
| | | | | | | | | | | | | | | | | | | This matches what we do with qmake, which means a build application can be deployed to either an iPhone or an iPad by default, without having to fiddle with Xcode settings. The device family will not be set if the target XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY property or the CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY variable has a value. There's also an opt-out variable called QT_NO_SET_XCODE_TARGETED_DEVICE_FAMILY Pick-to: 6.2 6.3 Fixes: QTBUG-100833 Change-Id: I8cde10975b44af81cfa18f985523c8ec1529386d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Split some iOS handling code into separate functionsAlexandru Croitor2022-05-201-1/+12
| | | | | | | Pick-to: 6.2 6.3 Change-Id: I722194c11ce2588ada78597129b5a185f1e9fc69 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add option to not include native libraries in APKTinja Paavoseppä2022-05-203-3/+47
| | | | | | | | | | | | | | | | | Sometimes it is not desirable to include the libraries in the APK, e.g. system and vendor apps could prefer having one set of libraries installed on the device. If unbundled deployment is specified, native libraries will not be included in the APK. With unbundled deployment, optional arguments can be passed to set the path to load the libraries on the device. [ChangeLog][Android][Deployment Changes] Adds option for Unbundled deployment, where native libraries are not packaged in the APK. Task-number: QAA-771 Change-Id: Ica51ef83a24dad58c7586bf610a58abe21fc1100 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QCoreApplication/QPostEventList: fix int/qsizetype mismatchesMarc Mutz2022-05-192-15/+15
| | | | | | | | | | | | Includes fixes in indexed for loops that are either known to modify the container under iteration, or else aren't known not to do it, so were kept as indexed loops, instead of being ported to ranged ones. Pick-to: 6.3 6.2 Task-number: QTBUG-103532 Change-Id: I7047b6127fbc4ac16ee113cfd6d1c71f2caba1e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QCoreApplication: port some indexed to ranged for loopsMarc Mutz2022-05-191-10/+6
| | | | | | | | | | | | ... fixing the int/qsizetype mismatches in the old code. These loops trivially don't modify the container under iteration, so using a ranged for loop is safe. Pick-to: 6.3 6.2 Task-number: QTBUG-103532 Change-Id: I1c9e1bffceea0ada54007d313aebe2e688fa9122 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qglobal.h: #include <stdbool.h> in C modeThiago Macieira2022-05-182-1/+1
| | | | | | | It's C99 and we require C11. Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4556b99f976 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix return value of qGlobalPostedEventsCount()Marc Mutz2022-05-182-4/+4
| | | | | | | | | | | | The unsigned return value was very un-Qt-ish, and, indeed, tst_QCoreApplication just stored the result in ints. Port to qsizetype, being the type of the expression that the function calculates. Task-number: QTBUG-103532 Change-Id: I95a81a686439b0686faad7a430adeaab66dc9e8d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make qGlobalPostedEventsCount() auto-test-exported-onlyMarc Mutz2022-05-182-2/+2
| | | | | | | | The only in-tree user outside QtCore is tst_QCoreApplication, guard the (single) test function there with QT_BUILD_INTERNAL. Change-Id: Ibc87ba76f2135cd8283acd75318f80a95e4b5c45 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove manual declarations of qGlobalPostedEventsCount()Marc Mutz2022-05-182-3/+1
| | | | | | | | | ... in favor of including qabstracteventdispatcher_p.h, where needed. Keeps the code DRY. Change-Id: I5bee2e653cb29ffac2601ff03c952a4b3adbdb9c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize atomics in QObject::moveToThread() [2/2]: de-duplicate loadsMarc Mutz2022-05-181-1/+1
| | | | | | | | | | | | | | We don't need to reload d->threadData, as we've already loaded it into a register three lines above, so use the already-loaded value. We don't care whether we might have read a different value the second time around, because that would mean we had a race condition elsewhere in the program (e.g. concurrent moveToThread() calls). Pick-to: 6.3 Change-Id: I29a27ca23302288b5900ac6b45b8690a80e85680 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Optimize atomics in QObject::moveToThread() [1/2]: relax a pointer loadMarc Mutz2022-05-181-1/+1
| | | | | | | | | | We don't need an acquire fence for checking a pointer for nullness, and we're not dereferencing the pointer later, so use a relaxed load there. Pick-to: 6.3 Change-Id: Id84e6fc50100f1bf6a4e33f89424f8b1cbb250cd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix data race in QObject::moveToThread()Marc Mutz2022-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | We dereference thisThreadData in the next line, at a point in time where we haven't, yet, verified that it's this_thread's QThreadData, so we need an acquire fence. The alternative would be to re-arrange the code so that dereferencing the pointer is delayed until after we verified it's this_thread's, but that doesn't seem readily possible. Even if it was easy, we'd first need to verify whether there are any writes into QThreadData objects after they've been constructed, in which case the acquire fence may be needed even in case it's 'ours'. So just add the acquire fence. Pick-to: 6.3 6.2 5.15 Change-Id: I468bc1f971bd87345bfcd6c13b7384bdf09d086a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* qobject_p.h: remove unused qreadwritelock.h includeMarc Mutz2022-05-172-1/+1
| | | | | | | | | | | | | | | | | Only qcoreapplication_p.h uses a QReadWriteLock (tanslationMutex), so include it only there. This include has caused QAtomicPointer<QReadWriteLockPrivate> to percolate to the top-5 of template instantiation hogs when compiling QtWidgets, as reported by Clang -ftime-trace. This patch improves that, because qcoreapplication_p.h isn't part of the PCH and is much less frequently included into QtWidgets TUs (68 instead of 142 times). Pick-to: 6.3 6.2 Change-Id: I2518040d83a04e7cef0645d7f4bf641fb50f49ff Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QPropertyBindingPrivate: de-inline functions that modify heapObserversMarc Mutz2022-05-172-16/+20
| | | | | | | | | | | | | Manipulating owning containers is costly at runtime, but also at compile-time, so don't do it in inline functions, do it out-of-line. Removes the top-2 entries[1] in a Clang -ftime-trace QtWidget build. [1] at the time of writing of this patch Change-Id: I5da5030788b0d976a0ab7875f87ba3b51dbb1231 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QReadWriteLock: fix another data race in stateForWaitCondition()Marc Mutz2022-05-171-0/+1
| | | | | | | | | The writerCount member variable is only ever accessed under Private::mutex protection, so we need to lock the mutex here, too. Pick-to: 6.3 6.2 5.15 Change-Id: I1717e5282eed2ecc14ccdc5090b9fc41174cccc8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix int/qsizetype mismatches in qstring.hMarc Mutz2022-05-171-7/+6
| | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QString] Fixed result truncation mod INT_MAX in fromStdSstring(), fromStdU16string(), fromStdU32string(), and fromStdWstring(). [ChangeLog][QtCore][QAnyStringView] Fixed result truncation mod INT_MAX in asLatin1StringView(). [ChangeLog][QtCore][QUtf8StringView] Fixed result truncation mod INT_MAX in toString(). Pick-to: 6.3 6.2 Change-Id: I944c561018a6ab4581ad6b1d71ec1ba1accba4a4 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Give some TLC to FlaggedDebugSignaturesMarc Mutz2022-05-171-7/+5
| | | | | | | | | - add noexcept - use std::array instead of C array - add comment explaining locations.size() Change-Id: Ied6c043e693fecc232878a00ea882c97bda150b6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QObject: Turn flaggedSignatures into a thread_local staticMarc Mutz2022-05-172-25/+22
| | | | | | | | | | | | | | | | | | | | ... out of QThreadData. No-one except two functions in qobject.cpp uses the object, and its creation is constinit, so there's no advantage to expose it to the world as a QThreadData member. Remove it from QThreadData, move the class' definition to the unnamed namespace in qobject.cpp, ensure constinit'ability by letting the language zero out the members (as opposed to an STL algorithm call), declare it constinit thread_local static, and adapt the two users (basically, removing the retrieval of QThreadData::current()). Almost no effect on Clang, but saves ~400 bytes on optimized GCC 11.2 Linux AMD64 C++20 builds. Change-Id: I22432d4ec5eb4ab59920656409b21768983fb4db Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJniHelpers: don't rely on qreadwritelock.h transitive includeMarc Mutz2022-05-171-0/+1
| | | | | | | | | | | ... from qcoreapplication_p.h Amends 5fd6704091febcc4abbc8d7ce06a393572524fa5. Pick-to: 6.3 Change-Id: I00bda35aa7bfd590105d7fe275af181ba7b53446 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Doc: Document qt_add_resources' OUTPUT_TARGETS argumentJoerg Bornemann2022-05-171-0/+6
| | | | | | | | | Originally, this argument was meant for internal use only. But it turned out useful for user projects too. Pick-to: 6.2 6.3 Change-Id: I58af5ca8303fa9166d41a0538a60913d1fba9784 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Add qsimd_x86_p.h to the QtCore source treeAlexey Edelev2022-05-171-0/+6
| | | | | | | | | | | | Need to collect all header files that belong to the module to make them visible in CMake source tree. In future commit they will be used to consider what headers need to be installed for each platform. Amends 28b4bd7dbbd4c0d4e2e04aff0ff885ec163975bc Change-Id: I7ab4063350254324869d5c2d0ba0f7e336da96fb Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Return specific types for frequently used Java objectsVolker Hilsheimer2022-05-176-9/+51
| | | | | | | | | | | | | | | | | | This allows us to specialize JNI type signature templates for e.g. the context object, which in Java signatures is "android/content/Context". Introduce a Q_DECLARE_JNI_TYPE macro that takes care of the plumbing. The types declared this way live in the QtJniTypes namespace, and transparently convert from and to jobject. Since jobject is a typedef to _jobject* we cannot create a subclass. Use a "Object" superclass that we can provide a QJniObject constructor for so that we don't require the QJniObject declaration to be able to use the macro. The APIs in the QNativeInterface namespace doesn't provide source or binary compatibility guarantees, so we can change the return types. Change-Id: I4cf9fa734ec9a5550b6fddeb14ef0ffd72663f29 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Fold methods for object return type into generic methodsVolker Hilsheimer2022-05-172-103/+126
| | | | | | | | | | | | | Since we know at compile time whether the return type is an object type, we can use 'if constexpr' and auto return type in the call(Static)Method and get(Static)Field functions to call the object-type methods. This makes the object-methods conceptually obsolete, but don't declare them as deprecated as long as they are still used in submodules to avoid warning floods and build failures in -Werror configurations. Change-Id: Ic3019ed990a9252eefcb02cdb355f8a6ed6bc2ff Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QString: don't use utf16() just to create a u16stringMarc Mutz2022-05-161-1/+1
| | | | | | | | | | | | QString::utf16() will detach from QStringLiterals in order to ensure NUL-termination, we don't need the returned pointer NUL-terminated, because we pass the length explicitly to the u16string ctor, so just use data(). Task-number: QTBUG-98763 Pick-to: 6.3 Change-Id: If883901a41480f469162ff4ed5bef927a3bf060a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QReadWriteLock: fix data race in stateForWaitCondition()Marc Mutz2022-05-161-1/+1
| | | | | | | | | | The function dereferences the load()ed pointer, so it needs an acquire fence. Pick-to: 6.3 6.2 5.15 Change-Id: Ib951de3f00851d915fec3392cdaba64f4a994300 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QReadWriteLock: fix data race in dtorMarc Mutz2022-05-161-1/+1
| | | | | | | | | | | | | | | | | | We need an acquire fence before we delete the d-pointer. Otherwise, the reads that the dtor performs (QReadWriteLockPrivate contains many non-trivial data types such as std::mutex and QVLA), race against writes performed in other threads. The qWarning() indicates that QReadWriteLock can not rely on external synchronization to ensure a happens-before relationship between reads in the dtor and said writes. While an explicit fence just before the delete would suffice, the guard return is an extremely unlikely error case, and if we ignore it, then loadAcquire() is correct, so use that. Pick-to: 6.3 6.2 5.15 Change-Id: I29773b665a7f864cd6b07a294da326e8b10399b5 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-16930-36443/+2091
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add variadic template overloads for QJniObject/Environment methodsVolker Hilsheimer2022-05-134-191/+301
| | | | | | | | | | | | | | | | | | | | | | | | | This allows the compiler to deduce the template arguments based on the provided method parameters, which we can then pass to the methodSignature and fieldSignature helpers to generate the signature string completely at compile time. Since we can't partially specialize template member functions, replace the specializations for void methods with compile-time-if branches in the general templates. This variadic template now prevents implicit conversion from the LiteralStorage types to const char* signatures, so catch the case where such a type ends up in the parameter list. Due to overload resolution rules for constructors, we need to explicitly disable the constructor if any of the arguments is a string literal type, as we have to keep the old C-style variadic function working for such calls. Add variations that use the variadic templates to the unit tests. Change-Id: I8734664b38bae932369462330a9a03302254c33c Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QVersionNumber: de-inline QList constructor calls and resize()Marc Mutz2022-05-132-12/+36
| | | | | | | | | | | | | | | | | | | The QList<int> range ctor and other QList<int> methods have percolated up near the top of the list of Clang -ftime-trace most expensive template instantiations in PCH libQt6Gui.so builds: **** Templates that took longest to instantiate: [...] 5138 ms: QList<int>::QList<const int *, true> (256 times, avg 20 ms) 4327 ms: QtPrivate::QCommonArrayOps<int>::appendIteratorRange<const int *> (256 times, avg 16 ms) The code in 6.3 is already sufficiently different for this patch to not be applicable there. Task-number: QTBUG-97601 Change-Id: I4420c8c90e472ecfd679b414cc4334d2ab55cce3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QObject: mark two error reporting functions COLDMarc Mutz2022-05-131-0/+2
| | | | | | | | | | | | | | They already nicely factored this error-only code from the normal path of execution. All that was missing was for them to be marked as COLD, so the compiler moves them out of the way even further, and optimizes them for size, not speed. TEXT size savings: ~400b on GCC 11.2 and ~500b on Clang 10 optimized C++20 AMD64 Linux builds. Pick-to: 6.3 6.2 5.15 Change-Id: I64a4123645855b4e34fbb0bc3304d144d7191a0d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix removal of trailing slashMarcus Tillmanns2022-05-131-6/+6
| | | | | | | | | | | | The fsevents implementation of QFileSystemWatcher on Mac OS X tries to remove trailing slashes from the paths when calling addPaths(). If the user tries to watch "/", the path is changed to "". The fix checks whether the path is longer than 1 before removing trailing slashes. Change-Id: Iafb10e449c4f3bd600b02edbe7c549911db05048 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>