summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
Commit message (Collapse)AuthorAgeFilesLines
...
* QTest::qWaitFor: make a comment terserMarc Mutz2024-03-141-3/+2
| | | | | | | | | | ...and adjust it to its presence in the new QDeadlineTimer overload, which sports nanoseconds granularity. Pick-to: 6.7 Change-Id: Ifa9658ca32c5dc4bef5cf36dec2e452174eebe1c Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTest::qWaitFor: remove superfluous qthread.h includeMarc Mutz2024-03-141-1/+0
| | | | | | | | | Amends 1abea5f5f13b4b8ec2a1c282e643b791cea12f30. Pick-to: 6.7 Change-Id: Ic4be7ed9508ae07eaa0f1d618090c8f44bb431fc Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTest::qWaitFor: scope a variable tighterMarc Mutz2024-03-141-2/+1
| | | | | | | | | | | | | | | | When fa296ee1dcf4c16fb6f242cf08949485e499fec3 ported this function from int timeout to QDeadlineTimer, the need to keep this variable outside the do-while so it could be checked in the loop exit condition fell away. Moving the definition of the variable to the first (and only) assignment makes the code clearer and the variable a constant. Amends fa296ee1dcf4c16fb6f242cf08949485e499fec3. Pick-to: 6.7 Change-Id: I7a0fe01dc68ff140beeb0e76b141c84d4bd28458 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Remove QObjectPrivate::isSender/senderList, no longer usedDavid Faure2024-03-142-36/+0
| | | | | | | | | Only QAccessibleWidget was using them, and this was changed some time ago. No point in keeping dead code. Change-Id: I14bc40e6d87df234987e82385ce13433c2b82744 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QSingleShotTimer: use the Duration alias from the event dispatcherThiago Macieira2024-03-131-7/+10
| | | | | | | | Just so we don't accidentally use different precisions. Amends commit bfc7535a10f7a6e3723f354b41f08a0fe1d18719. Change-Id: I83dda2d36c904517b3c0fffd17b5258e88dd194e Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QEventDispatcher*: port the Unix dispatchers to V2Thiago Macieira2024-03-1310-116/+111
| | | | | | | | | | | They're all ported in one go because all the changes are the same and they all rely on QTimerInfoList. The changes are: - use Qt::TimerId to uniquely identify timer IDs - use Duration (nanoseconds) to specify the timer interval - rename registeredTimers() to timersForObject(), which is const Change-Id: I83dda2d36c904517b3c0fffd17b52958767d8a68 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QTimerInfo: store nanoseconds instead of millisecondsThiago Macieira2024-03-135-30/+39
| | | | | | | | | | | | | | No change in behavior, other than the ability for the precise timers to be even more precise. There's a reduction in the stored interval range from 292 million years to 292 years, but there's no change in behavior because the timeout is stored as a steady_clock::time_point, which is nanoseconds with libstdc++ and libc++. Now, if there's an overflow, it'll happen on the call to registerTimer() instead of inside the calculation of the wake-up. Change-Id: I83dda2d36c904517b3c0fffd17b3d1f2d9505c1c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QAbstractEventDispatcher: port timer uses to the V2 APIThiago Macieira2024-03-134-10/+11
| | | | | | Change-Id: I83dda2d36c904517b3c0fffd17b52b71739928dc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QTimerInfo: correct CoarseTimer beyond the [20ms,20s] range earlierThiago Macieira2024-03-131-18/+16
| | | | | | | | Simplifies some code. Pick-to: 6.7 Change-Id: I83dda2d36c904517b3c0fffd17b3d18f2dfbc2b3 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QAbstractEventDispatcher: add an adaptation layer to use V2 methodsThiago Macieira2024-03-132-0/+49
| | | | | | | | This way, we can begin using the V2 methods now, regardless of whether the concrete dispatcher class has been ported or not. Change-Id: I83dda2d36c904517b3c0fffd17b52a6256b083af Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Short-live QAbstractEventDispatcherV2Thiago Macieira2024-03-133-13/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | This class is a temporary hack to enable transition to an API based on std::chrono for the Qt event dispatcher. In Qt 7, it will be merged with QAbstractEventDispatcher, replacing the pure virtuals there with the ones defined here. The new API differs from V1 in the following ways: - uses Qt::TimerId instead of int to identify timer IDs, so we can't accidentally confuse them with something else - uses Duration (nanoseconds) to specify the interval, instead of a mix of int and qint64 - add the missing const to remainingTime() - rename registeredTimers() to timersForObject() (I'd have kept the original name but we can't overload the name if the parameters are exactly the same; we could have used QT6_DECL_NEW_OVERLOAD_TAIL, but I think the new name is actually better) Because the old API was mixing int and qint64, we didn't officially support any timer for more than 2^31 ms (~24.85 days). This should extend the valid range to 292 years once the dispatchers are ported over. Change-Id: I83dda2d36c904517b3c0fffd17b3a7e0afef4b59 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QTest::qWaitFor(., int): restore lost Qt::PreciseTimer'nessMarc Mutz2024-03-131-1/+1
| | | | | | | | | | | | | | | | | Before the qWaitFor() port from int to QDeadlineTimer, the implementation constructed a QDeadlineTimer internally, passing int timeout and Qt::PreciseTimer. The int overload that was retained for source-compatibility, however, constructs the QDeadlineTimer without the PreciseTimer flag, which is a behavior change. Restore the Qt 6.6 behavior and pass Qt::PreciseTimer. Amends fa296ee1dcf4c16fb6f242cf08949485e499fec3. Pick-to: 6.7 6.7.0 Change-Id: Ib8e5b912c74b70d32a77195edb0d2a30cd7c241d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Bootstrap: remove QVariantThiago Macieira2024-03-133-15/+40
| | | | | | | | | I added QT_NO_VARIANT to qconfig-bootstrapped.h to be clearer on what the #ifs are, but there's no testing of that feature outside of QT_BOOTSTRAPPED. Change-Id: I01ec3c774d9943adb903fffd17b7e8ac4340fb89 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Bootstrap: remove QDataStreamThiago Macieira2024-03-132-8/+11
| | | | | | | | | | | It was only used by the cmake_automoc_parser so it would write a 64-bit in big-endian format. So bypass QDataStream and write it native endianness. Change-Id: I01ec3c774d9943adb903fffd17b79c78e56db4cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QVariant: use comparison helper macrosIvan Solovev2024-03-122-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | The relational operators were removed in 8652c79df0a47264a2d525424484e15744e2462b with the argument that they do not have a total order. Back than it was a valid argument, because Qt did not support any of the C++20 ordering types. Now Qt has its own implementation for all three ordering types, so we could technically add relational operators and claim that QVariant provides partial ordering. However, that could potentially lead to many bugs and/or unexpected results, if people start using QVariant as a key in std::map/QMap containers. We do not want that to happen, so we only use the helper macros to implement (in)equality operators. This commit also extends the unit tests, providing more extensive testing of (in)equality operators and the pre-existing QVariant::compare() method. Fixes: QTBUG-113234 Change-Id: I783f3b5df552da782627f4ed0a5bb1b577753a23 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QObject: fix a documentation note in the destructorGiuseppe D'Angelo2024-03-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | The docs for ~QObject say: > any pending posted events for the object are removed from the event > queue but then they also say: > Deleting a QObject while pending events are waiting to be delivered > can cause a crash These two contradict each other. In fact, the first one is correct, the second one is factually incorrect. Amend it to what I believe it's the intended meaning: do not destroy a QObject which is _handling_ an event (i.e. we're into QObject::event() or an override). Change-Id: Id1d564f296e17a764e0f49ebfedf6e292085c221 Pick-to: 6.7 6.6 6.5 6.2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Shantanu Tushar <shantanu.tushar@kdab.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* JNI: Fix error with overload resolution when passing string typesVolker Hilsheimer2024-03-061-1/+4
| | | | | | | | | | | | | | | | | | | | The variadic templates are supposed to be removed from the overload set when any of the parameters is a literal string type, as otherwise we get conflicts with the legacy overload taking class names and signatures as const char *. The detection of a literal string types was missing a few specializations, so that we ended up with the wrong overload being called, and class names getting interpreted as method names instead. Add the missing specializations, and add more test coverage for using the old overloads. Task-number: QTBUG-122235 Pick-to: 6.7 Change-Id: I5488f2009c8f62d74fac6754844f57cf64011414 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Rami Potinkara <rami.potinkara@qt.io> Reviewed-by: Lauri Pohjanheimo <lauri.pohjanheimo@qt.io>
* Revert "Fix export of QDeferredDeleteEvent, should be Q_CORE_EXPORT"Marc Mutz2024-03-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit bc3b18764aabf95a50a65e090863c54b6ac57e3e. Reason for revert: QDeferredDeleteEvent changed the size in 6.7. It is more important to protect the casual user that relied on the mention of the otherwise undocumented class in the QEvent::Type::DeferredDelete documentation than to be convenient for one tool, developed by experts who know how to replace their dynamic_cast with a type() check and a static_cast and/or extract information from an unexported class. In fact, not even the autotest-export is needed, as there are no mentions of the class outside of comments outside QtCore. Found in API-review. [ChangeLog][QtCore][QDeferredDeleteEvent] Made this undocumented class private and unexported. You will still be able to see the definition in qcoreevent_p.h, but you won't be able to create objects of the class anymore. Change-Id: I8a47c69d356a0bef260e7987bc4eab96430e8072 Pick-to: 6.7 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QCoreApplication: work around gcc 11.3 compiler bugChristian Ehrlicher2024-03-041-1/+1
| | | | | | | | Fix the amiguity in the comparison of a QByteArray and a char* Task-number: QTBUG-117661 Change-Id: Ic5142b7bc2a8220d244312414618028e8cc50d09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Mention QChronoTimer in API docsAhmad Samir2024-03-039-33/+46
| | | | | Change-Id: Iaf9fb31994f1580b2051dbd0b1b8eef2a218aa39 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Timers: add Qt::TimerId enum classAhmad Samir2024-03-0310-47/+83
| | | | | | | | | | | | | | | | | | | | | | | | Which will be used to represent timer IDs. Thanks to Marc for the idea to use "a strongly typed int". QTimer got a new id() method that returns Qt::TimerId (can't overload timerId()). Various classes in qtbase have a member named timerId(), but a new method is needed anyway in QTimer so id() it is (this is the reason QChronoTimer only has id() and no timerId()). Besides timer.timerId() has an extra "timer". This commit fixes the inconsistency between QObject using `0` timer id to indicate "failed to start", while QTimer::timerId() returned `-1` to indicate "timer is inactive". QTimer::id(), being a new method and all, now returns Qt::TimerId::Invalid, which has value `0`, so that the values match between the two classes. Extend the unittests to ensure QTimer::timerId()'s behavior is preserved. [ChangeLog][Core][QObject] Added Qt::TimerId enum class, that is used to represent timer IDs. Change-Id: I0e8564c1461884106d8a797cc980a669035d480a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Q{Chrono}Timer: de-duplicate some codeAhmad Samir2024-03-033-12/+11
| | | | | | | | | | | | Q{Chrono}Timer::isActive() has to use isActiveData so that the bindable property is correctly queried. However in other places in the code we can take a shortcut by checking id > 0. So rename QTimerPrivate::isActiveActualCalculation() to make it more palatable and use it throughout the code. Change-Id: I3378233e553fd860d9f105bba013dc9ffc31a2ba Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QChronoTimer, a timer with nanoseconds precisionAhmad Samir2024-03-035-532/+333
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The interval in QTimer is a QProperty of type int, which means it's limited to the number of milliseconds that would fit in an int (~24 days), this could cause overflow if a user constructs a QTimer with an interval > INT_MAX milliseconds. And it can't be easily changed to use qint64/std::chrono::nanoseconds: - changing the getters to return qint64 means user code would have narrowing conversions - the bindable QProperty interval can't be changed to qint64 during Qt6's lifetime without the risk of breaking user code - adding a new bindable QProperty that is qint64/nanoseconds is an option, but it has the complication of what to do with the int interval; set it when setInterval(milliseconds) is used by using saturation arithmetic? and what about notifying observers of the changed interval? Thus the idea of creating a new stop-gap class, QChronoTimer, as a cleaner solution. Both classes use QTimerPrivate. During the lifetime of Qt6, QTimer's interval range is about 24 days, whereas QChronoTimer's interval range is about 292 years (duration_cast<years>nanoseconds::max()). Currently the plan is to fold QChronotTimer back into QTimer in Qt7. Mark all QPropertyS in the new class as FINAL since they aren't intended to be overridden; this offers a performance boost for QML[1]. [1] https://lists.qt-project.org/pipermail/development/2024-February/044977.html [ChangeLog][QtCore] Added QChronoTimer, which uses a std::chrono::nanoseconds intervals, as a replacement for QTimer. Fixes: QTBUG-113544 Change-Id: I71697f4a8b35452c6b5604b1322ee7f0b4453f04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Copy QTimer source files to QChronoTimerAhmad Samir2024-03-032-0/+833
| | | | | | | Ultimately this is the best way to keep the log history of the code. Change-Id: I3413deffdb093a3239d65b6ca939e744224e722a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimer: delegate more to the chrono overloadsAhmad Samir2024-03-022-34/+57
| | | | | | | | | | | | | | | | | singleShot() (static) methods: QSingleShotTimer's interval isn't limited by the `int` interval in QTimer, so this is OK, no narrowing. start(int)/setInterval(int): Techincally it makes no difference which overloads delegate to which, because QTimer stores the interval in an `int` (QProperty); so any {int interval,chrono::milliseconds.count()} > INT_MAX is narrowing anyway. But it's less confusing and matches what has been done in other classes when porting them to chrono, int overload delegates to chrono overload. Change-Id: I5ae0888f16130ae28a74be4498a180485fa34550 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJniObject: use ctor delegation instead of construct+assignMarc Mutz2024-03-011-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old code used unintialized construction followed by (move) assignment to construct a QJniObject that requires a LocalFrame object. That is two constructors and therefore one more than we need (and need to destroy in inline code again). Everything can be solved with another level of indirection.™ Since the LocalFrame needs to remain alive for the duration of argument evaluation, the usual comma operator trick won't work. But we can add a private helper ctor that takes the LocalFrame as an additional argument to inject the object with the correct lifetime into the ctor delegation chain. Put the new argument in the front, to avoid clashes with the primary contructor's trailing universal references, which might be a better match than the new overload had we added the argument at the end. The hope is that the compiler will avoid the ensuing register shuffling by inlining the outer two constructor calls. This brings the number of QJniObjects constructed down to one, as it should be. We might also be able to remove the Uninitialized ctor again. Found in API-review. Amends 62cb5589b3723fe8162e190cd54d9c78929b98d2. Pick-to: 6.7 Change-Id: I326187e54fd0705a1bbedb2d51d94a46b108a3c8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Further replace 'Qt Designer' with 'Qt Widgets Designer'Kai Köhne2024-02-292-3/+3
| | | | | | | | | | Use \QD macro wherever possible. Amends 8aceccc7eb075 Task-number: QTBUG-122253 Change-Id: I276dabd40fb81486f6380fd90cf9968990932a24 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* JNI: support construction of QJniArray from std::initializer_listVolker Hilsheimer2024-02-262-2/+10
| | | | | | | | | | | Add implict constructor, treat the list like any other container. Simplify the test code, and explicitly constructor-initialize when we want an array and might have an array, so that we don't end up with constructing arrays of arrays. Change-Id: I14615f897cf8a2188510cfe1085ffc70a2396d5d Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QSingleShotTimer: use nanoseconds precisionAhmad Samir2024-02-233-19/+28
| | | | | | | | | | | | | | This is a step towards making QChronoTimer have nanoseconds precision. Not changing QTimer::singleShot() methods to take nanoseconds; QTimer uses milliseconds for the most part, having the static singleShot() methods take nanoseconds would be a bit surprising? [ChangeLog][Core][QObject] Added startTimer() nanoseconds overload and removed the milliseconds overload. This change is backwards compatible. Change-Id: I69e79c8feb6354846c6d3be57dc529af7abd1313 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* JNI: Move QJniArray constructor into the class bodyVolker Hilsheimer2024-02-231-11/+4
| | | | | Change-Id: Iae54afeef3b2017899c4ab1ec322efa3d0b819e2 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* JNI: don't depend on Qt-specific container API in QJniArrayVolker Hilsheimer2024-02-231-11/+13
| | | | | | | | Use std::size, std::data, std::begin instead of member functions that do not exist in e.g. std::initializer_list or arrays. Change-Id: I073b69f51ef93c2fe87104f1d7f8fbed3c603b33 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* JNI: Support QStringList as a parameter of native functionsVolker Hilsheimer2024-02-232-9/+37
| | | | | | | | | | | | | | | Since we support QString and QList specializations, we should also support QStringList directly. That's a bit more involved as we need to specialize the code path for QString, which is not convertible to or from jobject. But once we have mapped the type to jstring it follows the implementation for lists of objects. We now need to generate temporary local references when converting a QString to a jstring, so manage a local frame. We do so explicitly in chunks of 100 local references. Change-Id: I7ae5cf7d0ba0099992c36f3677980c346526804b Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* JNI: implement support for native functions taking a listVolker Hilsheimer2024-02-231-0/+27
| | | | | | | | | | | | | This didn't work yet because the partial specialization of the JNITypeForArgImpl factory was missing. Add a test case for QJniArray<double> and QList<double>. What doesn't work (yet) is QStringList for a native Java function taking a String[]. That will be added in a follow-up commit. Change-Id: I4d3fa0ecc04b98b9749f8358792f86c02ddbbc14 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* JNI: Support declared QtJniTypes in QJniArrayVolker Hilsheimer2024-02-221-3/+7
| | | | | | | | They can be treated like QJniObject, but are not QJniObject instances. Pick-to: 6.7 Change-Id: I419b6d0493f9a0ad3dcc726d48ac4c9ad3e6bc19 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Assert if CoUninitialize is called on wrong threadJøger Hansegård2024-02-212-0/+2
| | | | | | | | | | | | | Every call to CoInitialize on a thread must be paired up with a call to CoUninitialized on that same thread. QComHelper helps ensuring this, but if an object using QComHelper is not created and destroyed on the same thread, we end up in loosing this pairing. This patch helps detecting such issues. Task-number: QTBUG-121495 Change-Id: I07984437d1515d7ef61820d7152c339924b36e4b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Apple: Fix a few deprecation warnings after bumping deployment targetsTor Arne Vestbø2024-02-191-1/+1
| | | | | | | | | | | | - kIOMasterPortDefault -> kIOMainPortDefault - Use UTType instead of Carbon Core functions/constants - NSWorkspace iconForFileType -> iconForContentType - Removed obsoleted kUTTypeInkText pasteboard type There are still a few more, but these will be fixed in follow ups. Change-Id: Ibbca226d578b4ba64bd9c8c5d0addc1870114a20 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Documentation: Rename 'Qt Designer' to 'Qt Widgets Designer'Friedemann Kleint2024-02-191-1/+1
| | | | | | Task-number: QTBUG-122253 Change-Id: I04ab521decaf908b1c1491987f6de1e816a42a33 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* QTimer: make both defaultTypeFor() methods constexpr and noexceptAhmad Samir2024-02-172-8/+12
| | | | | | | | | | Also de-duplicate the code by using defaultTypeFor() in singleShot(), this way the comment and the calculation are done in one central place. Pick-to: 6.7 Change-Id: Ib822cae0e9228e546b664fbac728a60d65c4bbc3 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaObject: consistently use QByteArray(View) in the implementationIvan Solovev2024-02-161-9/+9
| | | | | | | | | | | | | The implementation was inconsistent. The `stringData()` method was returning QByteArray, while the `stringDataView()` method was returning QLatin1StringView. Update the second method to return QByteArrayView instead, and fix all related places. Found while trying to resolve ambiguities in QL1SV <-> QBAV comparison. Change-Id: I94f10a5eeeb80a6e512c1f7623becf5e7f543fd9 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Doc: Fix QDoc warnings for overloadsPaul Wicking2024-02-141-0/+3
| | | | | Change-Id: I9a77b6ea0026748c7f97f73b327118f7a9212d52 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Disable NSUserDefaults initialization workaround on iOSTor Arne Vestbø2024-02-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Core Foundation would fail to pick up defaults from command line arguments, as the logic to read the command line arguments was in the Foundation class NSUserDefaults. As a workaround, we initialized NSUserDefaults as early as we could, so that we could use Core Foundation elsewhere in Qt. As NSUserDefaults is considered a potential privacy risk, and needs explicit declaration of use for iOS in the privacy manifest, we disable the workaround for iOS. This should be okey, as the original issue does not seem to manifest on iOS 17, and was only a problem in practice when using command line arguments to debug things. The issue is also seemingly gone from macOS 14.3, but we keep the workaround in for now, just in case. Task-number: QTBUG-114319 Pick-to: 6.7 Change-Id: I2c698353673f797756a877a49cfbd8a37367c31e Reviewed-by: Doris Verria <doris.verria@qt.io>
* QTimer: do not set active state when setting a negative intervalIvan Solovev2024-02-122-6/+16
| | | | | | | | | | | | | | | | | | | | | | | QObject::startTimer() returns 0 in case of failure, for example when someone tries to register a timer with a negative interval. However, QTimer internally uses -1 as an invalid timer id. This could lead to a situation when the timer was not really started, but QTimer::isActive() returned true. This patch fixes it in two ways: - check the return value of QObject::startTimer() and treat 0 as an error. - do not treat 0 as a valid timer id when calculating the active state. As a drive-by: move the `using namespace std::chrono_literals;` declaration to the top of tst_qtimer.cpp, so that we do not need to repeat it in each test case. Fixes: QTBUG-122087 Pick-to: 6.7 6.6 6.5 Change-Id: I0e21152b2173ebb5fb0dada1b99a903a321ca9c4 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* Add virtual QObjectPrivate::writeToDebugStreamVolker Hilsheimer2024-02-102-4/+16
| | | | | | | | | | | | | QObject by default writes class- and objectName to the debug stream, but QObject subclasses might want to write different, or additional information. Providing class-specific debug stream operators is not a good solution for this, as it doesn't respect runtime polymorphism. With a virtual helper in QObjectPrivate, class authors can add an override. Change-Id: I382126ae5a56391d0c7e5ccb58fbbafa6aab5c77 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* wasm: fix onLoaded delay functionalityMorten Sørvig2024-02-082-11/+19
| | | | | | | | | | | | | | | | | | | | | | | onLoaded and the initial expose/paint should be sequenced such that onLoaded is fired first, followed by the expose. This makes sure that we don't spend any time on painting frames before Qt is completely initialized. Add a "requestUpdateHold" mode to QWasmCompositor (initially on) which disables requestUpdate calls, as well as releaseRequestUpdateHold() which enables requestUpdate calls again. This is a one-way transition; the mode can't be enabled again. This amends commit f2e22774 which implemented the concept of startup tasks, where onLoaded can be delayed until for instance font loading has been completed. After this commit the expose event and initial commit will be delayed as well. Change-Id: Icc784306726174fbabe8785d54485860e968745a Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
* Remove extra semi-colonsTasuku Suzuki2024-02-061-1/+1
| | | | | Change-Id: I92fddb36cd136fd1bd627955f15d0559b9942d7e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* core/gui: fix odr violationTim Blechmann2024-02-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | When linking Qt statically, QtCore and QtGui are not separated into different DSOs. when both statically linked versions of QtCore and QtGui are linked into the same binary with LTO, gcc emits: ``` /usr/src/debug/qtbase/6.3.0-r0/git/src/gui/painting/qicc.cpp:105: warning: type ‘Tag’ violates the C++ One Definition Rule [-Wodr] /usr/src/debug/qtbase/6.3.0-r0/git/src/corelib/kernel/qtranslator.cpp:78: note: an enum with different value name is defined in another translation unit /usr/src/debug/qtbase/6.3.0-r0/git/src/gui/painting/qicc.cpp:106: note: name ‘acsp’ differs from name ‘Tag_End’ defined in another translation unit /usr/src/debug/qtbase/6.3.0-r0/git/src/corelib/kernel/qtranslator.cpp:78: note: mismatching definition ``` we therefore define the `struct Tag` in an anonymous namespace or the QIcc namespace Change-Id: Ib4edeede35c51322ab1959d70fb87359b196e59b Pick-to: 6.5 6.6 6.7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix usage of std::enable_if_t to SFINAE out QProperty APIsVolker Hilsheimer2024-02-032-15/+9
| | | | | | | | | | Declare an IfUntypedPropertyData alias and use that consistently. Amends 311f8896322bcd39d33369c8311a8c89ccdad449. Pick-to: 6.7 Change-Id: If36ef8e2f9ce25e0ffe7b4b448c31ea5866acfc3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Change license of .qdoc filesLucie Gérard2024-02-021-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all .qdoc files should be LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I7c4d8a1957db6f6d7ad18cbc1928499724e9305f Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* JNI: Don't use forwarding reference in ranged forVolker Hilsheimer2024-02-021-1/+1
| | | | | | | | | The elements we iterate over are always jobjects, i.e. POD, so iterating over values is at least as efficient, and less unnecessarily clever. Pick-to: 6.7 Change-Id: I6142dab84f3d37d82613ecf27cc03dde7810e541 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* kernel: silence `-Wextra-semi`Tim Blechmann2024-02-021-1/+1
| | | | | | | | silencing gcc's `-Wextra-semi` Pick-to: 6.5 6.6 6.7 Change-Id: I0e70465585be5ba4d90c691cd0fbd43e1288e694 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>