summaryrefslogtreecommitdiffstats
path: root/src/corelib
Commit message (Collapse)AuthorAgeFilesLines
* qglobal.h: use the GCC attribute for nothrow in C modeThiago Macieira2022-05-271-1/+5
| | | | | | | There's exactly one use in Qt: the qVersion() function. Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4b3b9e2119a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qglobal.h: reorganize and simplify the C++11 keyword macrosThiago Macieira2022-05-271-64/+23
| | | | | | | | For the C side, I don't think any of the constexpr macros have ever been in use, but I'm leaving them. Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff47db2d26e4e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qglobal.h: remove superfluous C++11 check from Qt 5.6Thiago Macieira2022-05-271-6/+0
| | | | | | | | Superseded by the C++17 check in qglobal.h applicable to 6.0, but only added for 6.2 (commit 647c0e80ed2e190778016c4208b5d6f1f9fd6543). Change-Id: Ieb9a2aa1ea914b1b956bfffd16effa512e6f1e4a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add compile-time generation of JNI class namesVolker Hilsheimer2022-05-273-2/+47
| | | | | | | | | | | | | | | | | | | | | As with method signatures, register class names using template function specialization in the QtJniTypes namespace, and then declare C++ types as JNI classes with a class name string. Such classes implicitly get registered as JNI types as well. Add a QJniObject construct method (since C++ constructors that are templates cannot be explicitly instantiated with a type), and a QJniEnvironment::findClass overload. Add test coverage, also for the recently added macros for native methods. As a drive-by, change the name of the Q_JNI_DECLARE_NATIVE_METHOD macro to Q_DECLARE_JNI_NATIVE_METHOD for consistency. Change-Id: Ic19562d78da726f202b3bdf4e9354e8ad24d8bd9 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Core: make CLDR data constexprYuhang Zhao2022-05-272-30/+30
| | | | | | | Task-number: QTBUG-100485 Pick-to: 6.3 6.2 Change-Id: Ib8c5160ca0994662a5fdc2293dc734c1bdcac4f2 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Optimize QThreadPrivate::addObjectWithPendingBindingStatusChange()Marc Mutz2022-05-262-9/+14
| | | | | | | | | | | | | | | | | | | | | ... and bindingStatus() QBindingStatus* is the final state of the value chain in m_statusOrPendingObjects, so we can use the Double-Checked Locking Pattern to avoid locking the mutex when we already have a status - it won't go away again, unlike the vector in the List state. To enable the change, make the data member an atomic<>. All loads and stores can continue to use memory_order::relaxed, except the loads of a potential status, which have to acquire, and the store of the status, which has to release. This creates the necessary synchronizes-with relation. So even though we synchronize out of middle of the mutex critical section in QThread::exec() this way, there's no data race between QThread::exec() and a potential bindingStatus() call. Change-Id: I0e0b7bd305649fa5f56a0f8723fb75f2577b90dd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Core: make Unicode Database constexprYuhang Zhao2022-05-261-11/+11
| | | | | | | | Task-number: QTBUG-100485 Pick-to: 6.3 6.2 Change-Id: I41480a34b14fd86a68a5c10b7e0f3d250e785d0f Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix Windows display versionYuhang Zhao2022-05-261-5/+10
| | | | | | | | | The "ReleaseId" key's value stopped updating since Windows 10 20H2, so we should query the new "DisplayVersion" key when running on Windows 10 20H2 and onwards. Change-Id: Ifaa8287f9812126bde0390337af0cda23ff8e529 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Short live q20::remove_cvref{,_t}!Marc Mutz2022-05-261-0/+13
| | | | | | | | | | C++20 added this as a more light-weight alternative to std::decay. Task-number: QTBUG-103739 Change-Id: Icbb973d9500a0d1425859f8f104b7aef1ec917f1 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* q20functional.h: transitively include <functional>Marc Mutz2022-05-261-0/+2
| | | | | | | | | | | | | | | | | | We don't want to require users to say #include <functional> #include <q20functional.h> because that would leave duplicated <functional> includes after a mechanical s/q20functional.h/functional/. Mechanical transformation is the major design goal of the qNN namespaces, so fix this before we use the header in ever more places. Pick-to: 6.3 Change-Id: Id258c36a042214f41b737fb7ab60906cc8e76ca6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QMap: fix values() documentationGiuseppe D'Angelo2022-05-251-3/+1
| | | | | | | | | The body was still referring to the Qt 5 QMap where the same key could be mapping to multiple values. That's no longer the case in Qt 6. Change-Id: Idb1786ac45f328c318878fa52bf5d43d79c0178a Pick-to: 6.2 6.3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* macOS: Add private API to ensure that a process is responsible/disclaimedTor Arne Vestbø2022-05-252-0/+54
| | | | | | | | | Useful for tests that request permissions and need to ensure these are requested on behalf of the app itself, and not its parent process, regardless of how it's invoked. Change-Id: Iac493e95440a3a04df4fa466c1d700ba1233e393 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QStringConverter: Do not crash if invalidFabian Kosmale2022-05-251-4/+26
| | | | | | | | | | | Attempting to use an invalid QStringConverter would so far have resulted in a crash, as we would dereference the null iface pointer. Fix this by inserting adequate checks, and ensure that hasError returns true if we attempt to en/decode with an invalid converter. Pick-to: 6.2 6.3 Change-Id: Icf74bb88cd8c95685481cc0bd512da99b62f33e6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QUnicodeTools: Fix line breaking before open parenthesesIevgenii Meshcheriakov2022-05-241-4/+18
| | | | | | | | | | | | | | UAX #14, revision 45 (Unicode 13) has changed rule LB30 to only trigger if the open parentheses is non-wide: (AL | HL | NU) × [OP-[\p{ea=F}\p{ea=W}\p{ea=H}]] This fixes the remaining 24 line break tests. Task-number: QTBUG-97537 Pick-to: 6.3 Change-Id: I9870588c04bf0f6ae0a98289739bef8490f67f69 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Unicode: Extract EastAsianWidth propertyIevgenii Meshcheriakov2022-05-242-9759/+9911
| | | | | | | | | | This property is needed to properly implement the line breaking algorithm from UAX #14. Task-number: QTBUG-97537 Pick-to: 6.3 Change-Id: Ia83cc553c9ef19fae33560721630849d2a95af84 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix line breaking for potential emojisIevgenii Meshcheriakov2022-05-241-0/+11
| | | | | | | | | | | | | | Implement part of LB30b introduced by UAX #14, revision 47 (Unicode 14.0.0): [\p{Extended_Pictographic}&\p{Cn}] × EM This fixes one line breaking test. Task-number: QTBUG-97537 Pick-to: 6.3 Change-Id: I3fd2372a057b7391d8846e9c146f69a54686ea61 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix interactions of WB3d and WB4 rulesIevgenii Meshcheriakov2022-05-241-2/+7
| | | | | | | | | | | Word breaking rule WB3d should not be affected by WB4. This fixes the remaining word break test. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I99aee831d7c54fafcd2a9d526a3e078b12c5bfad Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Handle WB3c word break ruleIevgenii Meshcheriakov2022-05-241-2/+12
| | | | | | | | | | | | | | | Adjust handling of WB3c rule to UAX #29, revision 33 (Unicode 11.0.0). The rule reads: ZWJ × \p{Extended_Pictographic} This fixes 9 word break tests. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I818d4048828e6663d5c090aa372d83f5099fdffe Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Unicode: Remove obsolete word break classesIevgenii Meshcheriakov2022-05-243-33/+25
| | | | | | | | | | Remove E_Base, Glue_After_Zwj, E_Base_GAZ, and E_Modifier obsoleted by UTS #29, version 33 (Unicode 11.0.0). Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: If5dc36ae17cd8746bbe81b73bbcc0863181e4a7a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Adjust properties of WSegSpace word break classIevgenii Meshcheriakov2022-05-241-23/+23
| | | | | | | | | | | | | | | | | | Disable break between sequences of WSegSpace characters (rule WB3d, introduced in UAX #29, version 33, Unicode 11.0.0). Also disable breaks between WSegSpace and (Extend | Format | ZWJ) due to rule WB4. Adjust "words4" test to take the above changes into account (space character belongs to WSegSpace). Mention the full class name in a comment inside the word break table. This fixes 34 word break tests. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I7dfe8367e45c86913bb7d7fe2adb053711978487 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix handling of LB22 line break ruleIevgenii Meshcheriakov2022-05-241-11/+11
| | | | | | | | | | | | | | This rule was simplified in version UTS #14 version 45 (Unicode 13.0.0) to read: × IN Re-enabled 28 fixed line break tests. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I1c5565a8c1633428c22379917215d4e424ff0055 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Remove ZWJ data from the line break tableIevgenii Meshcheriakov2022-05-241-38/+37
| | | | | | | | | | | ZWJ is handled separately by rule LB8a. The code for rule LB10 was adjusted to handle ZWJ as AL as required by the specification. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I814cbb4a26f2994296767cca0443d8a1a1aaf739 Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUnicodeTools: Fix handling of ZWJ for line breaksIevgenii Meshcheriakov2022-05-241-3/+2
| | | | | | | | | | | | | | | Adjust implementation of rule LB8a of UAX #14. The rule was changed in version 41 (corresponding to Unicode 11.0.0): ZWJ × (ID | EB | EM) ⇒ ZWJ × Fixing this rule fixes 9 line break tests. Those are re-enabled. Task-number: QTBUG-97537 Pick-to: 6.2 6.3 Change-Id: I1570719590a46ae28c98ed7d5053e72b12915db7 Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix race conditions in moveToThreadFabian Kosmale2022-05-243-33/+135
| | | | | | | | | | | | | Amends ba6c1d2785ca6d8a8b162abcd9d978ab0c52ea2d, which made m_statusOrPendingObjects already atomic, but did not handle concurrent deletion/push_back of the pendingObjects vector correctly. We use the existing lock in QThreadPrivate to prevent data races. Pick-to: 6.2 6.3 Fixes: QTBUG-101681 Change-Id: I0b440fee6ec270d762e6700a4fe74f28b19e75e8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QStringConverter: use the QUtf8 codec when Windows is using UTF-8Thiago Macieira2022-05-232-4/+32
| | | | | | | | | | | | | | | | | | | | The QLocal8Bit implementation assumes that there's at most one continuation byte -- that is, that all codecs are either Single or Double Byte Character Sets (SBCS or DBCS). It appears to be the case for all Windows default codepages, except for CP_UTF8, which is an opt-in anyway. Instead of fixing our codec, let's just use the optimized UTF-8 implementation. [ChangeLog][Windows] Fixed support for using Qt applications with UTF-8 as the system codepage or by enabling that in the application's manifest. Discussed-on: https://lists.qt-project.org/pipermail/interest/2022-May/038241.html Pick-to: 6.2 6.3 Change-Id: I77c8221eb2824c369feffffd16f0912550a98049 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QVector: make sure the forwarding headers for the Java iterators existThiago Macieira2022-05-231-0/+6
| | | | | | | | | | | | | | They used to in Qt 5. And now they do again: $ grep . include/QtCore/Q*Vector* include/QtCore/QMutableVectorIterator:#include "qvector.h" include/QtCore/QVector:#include "qvector.h" include/QtCore/QVectorIterator:#include "qvector.h" Pick-to: 6.2 6.3 Fixes: QTBUG-103742 Change-Id: I77c8221eb2824c369feffffd16f128a983f4866c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix CLDR version in qt_attribution.jsonIevgenii Meshcheriakov2022-05-231-2/+2
| | | | | | | | | CLDR was updated to version 41 in 59860685a19017b50e8fd54c3397a190585c8ebc but this file was not updated. Task-number: QTBUG-103663 Change-Id: I163a4a3f6ce16d611c013656fa569be01880e72c Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Compile-time generate a JNINativeMethod from a C functionVolker Hilsheimer2022-05-232-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a template function that allows us to get the method signature string from a free function, which are used as native callbacks methods from Java. Provide a macro that defines a signature object, and a JNINativeMethod object based on it, in an internal namespace so that we don't pollute the namespace with generated names. Add another macro to get the generated JNINativeMethod object based on the free function name. Lastly, add overloads to QJniEnvironment::registerNativeMethods that take a std::initializer_list of JNINativeMethods. We can now declare a free function to be a JNI native method: static bool callbackFromJava(JNIEnv *e, jobject /*thiz*/, jstring p1) { // ... } Q_JNI_DECLARE_NATIVE_METHOD(callbackFromJava); and register it with the JNI environment like this: QJniEnvironment jni; jni.registerNativeMethods(clazz, { Q_JNI_NATIVE_METHOD(callbackFromJava) }); removing a significant amount of boiler plate code. Change-Id: Ie4007b24125879fed3dae1f4d232b4aa95999b44 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* qglobal: resolve one Qt6 TODOYuhang Zhao2022-05-231-12/+4
| | | | | | | | Tested with MSVC 2022 locally and this change doesn't break the bootstrapped builds. Change-Id: Ieeb9a77035d889b9c1ed0c0c3488ac8802879282 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Implement in QLocalTime the offset functions V4 Date needsEdward Welbourne2022-05-222-0/+56
| | | | | | | | | | | | Prepare to replace a large pile of #if-ery-laden tangled mess from the implementation of V4 Date by implementing a cleaned-up version of one of its offset calculations and using a recently refactored API of QDTP to implement the other. Task-number: QTBUG-95993 Change-Id: I469f67fb384543abeece9ce8b14bb294c8613033 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>