summaryrefslogtreecommitdiffstats
path: root/src/corelib/compat
Commit message (Collapse)AuthorAgeFilesLines
* QRegularExpression: use modernize comparisonsTatiana Borisova3 days1-0/+5
| | | | | | | | | | | | | Replace class operators operator==(), operator!=() of QRegularExpression to friend method comparesEqual() and Q_DECLARE_EQUALITY_COMPARABLE macro. Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Task-number: QTBUG-120304 Change-Id: Ib6fc83d29ad9bc710c2fdf32a3d60131fbf298b6 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QtCore/removed_api: fix 6.8 block order, global includeMarc Mutz7 days1-3/+3
| | | | | | | | | | | | | | | | | | | | | | There must be no include other than qglobal.h¹ outside QT_CORE_REMOVED_SINCE blocks, otherwise REMOVED_SINCE in that header might not work correctly. Move the include to the block in which it's used. ¹ and we should eventually reduce that to the bare minimum, too. This include is still from the time when there was only the monolithic qglobal.h. Amends bfc7535a10f7a6e3723f354b41f08a0fe1d18719. Also move the qstring.h block which was not in alphabetical order. Amends 42b6fdfb523f47ba711138bb299d97823e7c64d2. Change-Id: I997ebf0028e31ef86145d2d0c7455e7c54bbf7e9 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QMimeType: use modernize comparisonsTatiana Borisova9 days1-0/+7
| | | | | | | | | | | | | Replace class operators operator==(), operator!=() of QMimeType to friend method comparesEqual() and Q_DECLARE_EQUALITY_COMPARABLE macro. Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Task-number: QTBUG-120304 Change-Id: I9776e98c8a3b14d599733c91af61fbc12b1f0e57 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QSettings/removed_api: don't return <void expr>Marc Mutz10 days1-1/+1
| | | | | | | | | | Fixes clazy-returning-void-expression. Amends 4cf299eb5bbdbac8484c2ee8c5afbd260dccc6d5. Pick-to: 6.7 6.5 Change-Id: I6192deb82afe9a5ba7ddaf6203d4046f518c545a Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QRegularExpressionMatch: port API from QString to QAnyStringView keysMatthias Rauter10 days1-0/+34
| | | | | | | | | | | | | | The QRegularExpression capture-by-name keys are currently QStringViews, but are only ever used to compare them against a const char16_t*, so this API is a perfect candidate for replacing all of these overload sets with a single QAnyStringView function. [ChangeLog][QtCore][QRegularExpression] Keys can now be passed as QAnyStringView (was QStringView). Fixes: QTBUG-103097 Change-Id: I1a80e85f301cc08370d70b3b5eb0ae10c6a51f33 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QTimer/QObject::startTimer: improve the detection of overflowThiago Macieira12 days1-4/+6
| | | | | | | | | | | | | | | | | | | | | | Converting from int milliseconds to int64_t nanoseconds can't overflow (it won't even for picoseconds, so we'll be fine for a couple more decades), so we only need to address the cases where the millisecond value was passed in int64_t: that is, in the std::chrono::milliseconds overloads. For the other cases, I added a comment. Amends bfc7535a10f7a6e3723f354b41f08a0fe1d18719 to not allow the detected overflow to happen at all, which could cause the timer to become very small. Instead, we saturate to the maximum, which is about 292 years (just under 106752 days). That's longer than computers have existed, so the chance that some Qt application is still running on a computer without any reboots from today to 24th century is remote at best. This parallels QDeadlineTimer, which already has code to saturate when using milliseconds. Change-Id: I6818d78a57394e37857bfffd17b9b1465b6a5d19 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QBitArray: use new comparison helper macrosTatiana Borisova13 days1-0/+1
| | | | | | | | | | Replace public friend operators operator==(), operator!=() of QBitArray to friend method comparesEqual() and Q_DECLARE_EQUALITY_COMPARABLE macro. Task-number: QTBUG-120304 Change-Id: I6b47111c144016b3aa05f01c8035c32d164291ad Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Move int QObject::startTimer() to the alphabetically ordered placeTatiana Borisova13 days1-13/+13
| | | | | | Change-Id: Ibd1f0ef1c57e8aa31ea7b42b2874ba860d9c4373 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QItemSelectionRange: use new comparison helper macrosTatiana Borisova2024-04-181-0/+2
| | | | | | | | | | | | Replace public operators operator==(), operator!=() of QItemSelectionRange class to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Task-number: QTBUG-120304 Change-Id: Ideff990c942d5ee1c89a93ac2081cc5d7067b23f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QJsonObject: use new comparison helper macrosTatiana Borisova2024-03-251-0/+13
| | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonObject to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Add friend method comparesEqual(QJsonObject, QJsonValue) to the QJsonObject class, to support comparison between QJsonObject and QJsonValue elements, see test-case valueEquals(). Task-number: QTBUG-120300 Change-Id: Ibab0b4b39966205447e31c41e94e7e1a4e31e553 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QJsonValue: use new comparison helper macrosTatiana Borisova2024-03-221-0/+12
| | | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonValue/QJsonValueConstRef/QJsonValueRef classes to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Delete non-exported public operators operator==(), operator!=() for QJsonValueConstRef/QJsonValueRef classes. Add comparison check to auto-test. Task-number: QTBUG-120300 Change-Id: I01434af4ce5a7589733db4a9b14f54ad42e852ed Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QJsonDocument: use new comparison helper macrosTatiana Borisova2024-03-221-0/+7
| | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonDocument to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Task-number: QTBUG-120300 Change-Id: I7b61765c34406b7a9fb7dd8b1fc554c87af6a3f3 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QJsonArray: use new comparison helper macrosTatiana Borisova2024-03-211-0/+12
| | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=() of QJsonArray to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Add friend method comparesEqual(QJsonArray, QJsonValue) to the QJsonArray class, to support comparison between QJsonArray and QJsonValue elements, see test-case fromToVariantConversions() Task-number: QTBUG-120300 Change-Id: I8440ca0761bede8551ff792bfa7f22e47b56fa79 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Xml: use new comparison helper macrosTatiana Borisova2024-03-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | New comparison macros are used for following classes: -QXmlStreamAttribute -QXmlStreamNamespaceDeclaration -QXmlStreamNotationDeclaration -QXmlStreamEntityDeclaration Replace public operators operator==(), operator!=() of classes to friend methods comparesEqual(); Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods and replace them with a friend. Add checkStreamNotationDeclarations()/checkStreamEntityDeclarations() test-cases to test change. Task-number: QTBUG-120300 Change-Id: I0b5642b2e23cc21ede7bc4888f0a9bddd6c08d07 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborMap: use new comparison helper macrosTatiana Borisova2024-03-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=(), operator<() of QCborMap to friend methods comparesEqual() / compareThreeWay(). Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods and replace them with a friend. Delete #if 0 && __has_include(<compare>) blocks, since they are not required anymore. Add friend methods comparesEqual(QCborMap, QCborValue) and compareThreeWay(QCborMap, QCborValue) to the QCborMap class, to support comparison between QCborMap and QCborValue elements, see test-case mapSelfAssign() -> QT_TEST_EQUALITY_OPS(it.key(), QCborMap({{0, v}}), true); Task-number: QTBUG-120300 Change-Id: I9e33df255d16484efd3124cf0632db859408fb5d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QCborArray: use new comparison helper macrosTatiana Borisova2024-03-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Replace public operators operator==(), operator!=(), operator<() of QCborArray to friend methods comparesEqual() / compareThreeWay(). Use QT_CORE_REMOVED_SINCE to get rid of current comparison methods and replace them with a friend. Delete #if 0 && __has_include(<compare>) blocks, since they are not required anymore. Add friend methods comparesEqual(QCborArray, QCborValueConstRef) and compareThreeWay(QCborArray, QCborValueConstRef) to QCborArray to support comparison between QCborArray and QCborValueRef/QCborValueConstRef, see test-case mapMutation(). Add QT_TEST_EQUALITY_OPS/QT_TEST_ALL_COMPARISON_OPS tests for QCborArray test-cases. Task-number: QTBUG-120300 Change-Id: Ifad1a04c61363618e8bba73cf7c87757552d722a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QCborValue: use new comparison helper macrosTatiana Borisova2024-03-181-0/+2
| | | | | | | | | Add qcborvalue.h header to removed_api.cpp file Ammends from 15da9c75d0a05b7451a35b5b6a3c940f9cb85143 Task-number: QTBUG-120300 Change-Id: Ic33bf80298730f2c3fd408ffb45f0e1b32f531fc Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QUrl: Use new comparison helper macrosRym Bouabid2024-03-061-0/+17
| | | | | | | | | | | | | | | | The class had operator==(), operator!=() and operator <() defined as public member functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of these methods and replace them with hidden friends. Use QT_TEST_ALL_EQUALITY_OPS macro in unit-tests. Use new \compares command in the documentation to describe the comparison operators provided by QUrl. Task-number: QTBUG-120303 Change-Id: Ic4fa2335292cc4b75ad2373832c0b89d768f529c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimer: delegate more to the chrono overloadsAhmad Samir2024-03-021-0/+2
| | | | | | | | | | | | | | | | | 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>
* QString: use comparison helper macros - comparison with byte arrays [2/3]Ivan Solovev2024-03-021-0/+3
| | | | | | | | | | | | | | | | | | Use the comparison helper macros to replace the member relational operators for comparison with QByteArray and const char *. As QString and QByteArray are exported, we cannot simply remove the inline methods, so wrap them into QT_CORE_REMOVED_SINCE. Add relational operators with QByteArrayView. Provide more unit-tests for the comparison with the byte array types. This enables operator<=> for QString vs byte arrays in C++20 builds. Task-number: QTBUG-117661 Change-Id: I305343e1b6c5d78b10f2976573db4e904ba6b44b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QOperatingSystemVersion: clean up after QOSVBase extractionMarc Mutz2024-02-251-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When 3446313c7a5cd6005089866a7b20c9f28e132a0a extracted most functions from QOperatingSystemVersion to a new unexported QOperatingSystemVersionBase, for BC reasons, it kept the existing QOSV methods as (inline or out-of-line) forwarders to the new QOSVBase ones. But the only ones that are actually still required are currentType(), type(), and isAnyOfType(), because their Base equivalents use a different enum type (we should probably make the OS Type an enum in namespace Qt instead; other patch). The others can just be REMOVED_SINCE, and should be, to make new code use the base class implementations, where inlining and constexpr properly work (they don't, on Windows, in exported classes). Re-use the existing REMOVED_SINCE(6,3) block in removed_api.cpp to move these functions there. Amends 3446313c7a5cd6005089866a7b20c9f28e132a0a. Reverts a tiny part of 215677818470e48e9090d7ae4411e1fea62207b8 (will conflict in backports). Pick-to: 6.7 6.6 6.5 Change-Id: I1d7ba784634ccd7c9ba5f7ceddb15b7787468d31 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QSingleShotTimer: use nanoseconds precisionAhmad Samir2024-02-231-0/+15
| | | | | | | | | | | | | | 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>
* QUrlQuery: Use new comparison helper macrosRym Bouabid2024-02-231-0/+7
| | | | | | | | | | | | | | | QUrlQuery had operator==() and operator!=() defined as public member functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of these methods and replace them with a hidden friend. Use QT_TEST_ALL_EQUALITY_OPS macro in unit-tests. Use new \compares command in the documentation to describe the comparison operators provided by QUrlQuery. Task-number: QTBUG-120303 Change-Id: I083487a134887010ebbb78906d2c1982f2ad41b5 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QProcessEnvironment: Use new comparison helper macrosRym Bouabid2024-02-221-0/+9
| | | | | | | | | | | | | | | QProcessEnvironment had operator==() and operator!=() defined as public member functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of these methods and replace them with a hidden friend. Use QT_TEST_ALL_EQUALITY_OPS macro in unit-tests. Use new \compares command in the documentation to describe the comparison operators provided by QProcessEnvironment. Task-number: QTBUG-120303 Change-Id: I4c57f6cfb9589e82a37eea6993e079212b34cecd Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QDataStream: reimplement and constrain operator<<(bool)Giuseppe D'Angelo2024-02-201-0/+5
| | | | | | | | | | | | | | | | | Instead of offering it as a plain overload, make it a template and constrain the argument to be precisely bool. This removes the danger of accidentally streaming things that are convertible to bool, such as pointers, by, indeed, converting them to bool. This allows us to remove the deleted overloads for pointers to objects and pointers to members. The existing operator<<(bool) is exported, hence I moved it into removed_api.cpp. Since the implementation required private QDataStream APIs, I've just "inlined" the implementation that simply routed through the operator<<(qint8) overload. Change-Id: I3c0a9811bf5c9e734e28514b37bcaaddb09ada25 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileInfo: Use new comparison helper macrosRym Bouabid2024-02-141-0/+7
| | | | | | | | | | | | QFileInfo had operator==() and operator!=() defined as public member functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of these methods and replace them with a hidden friend. Use QT_TEST_ALL_EQUALITY_OPS macro in unit-tests. Task-number: QTBUG-120303 Change-Id: Ie290df230b0f608a0965dccba9184382291cad8e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QDir: Use new comparison helper macrosRym Bouabid2024-02-131-1/+7
| | | | | | | | | | | | QDir had operator==() and operator!=() defined as public member functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of these methods and replace them with a hidden friend. Use QTestPrivate::testEqualityOperators() helper function in unit-tests. Task-number: QTBUG-120303 Change-Id: I86c2ba18b8b114efd9f62fc2fd628bc9065b04b2 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QDataStream: inline status()Marc Mutz2024-02-121-0/+11
| | | | | | | | | | | | | The implementation is trivial, and unchanged since the beginning of the public project history, so I'd venture that it's safe to commit to it not changing until Qt 7 at this point. The reason to make it inline is that a good stream operator implementation should be checking the stream state quite often, so we shouldn't make that an expensive DLL entry point. Change-Id: Iba8cbfbaf02326c86ab95be17b603cd2e785f78c Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Deprecate QDataStream::readBytes(char *&, uint &) instead of removing itIvan Solovev2024-02-071-14/+0
| | | | | | | | | | | | | | | | | | | | | | We cannot remove the overload using QT_REMOVED_SINCE, because a qint64 lvalue in the new overload will not bind to an uint& parameter, so the old code would not compile. Deprecate the old overload, and add a unit-test that makes sure that it still behaves correctly. This commit also introduces the new deprecation macros that are required to do the deprecation in Qt 6.11. Amends fd48ce0b73c74dafd5db27bc1f2752ef665df7ef Found in 6.7 API review Pick-to: 6.7 Change-Id: I02893bfbe040df736f8e746384e0261a0f0041d3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDataStream: use qint64 to represent size while reading and writingIvan Solovev2024-02-071-15/+6
| | | | | | | | | | | | Do that to avoid narrowing at the call site on 32-bit platforms. Amends fd48ce0b73c74dafd5db27bc1f2752ef665df7ef Found in 6.7 API review Pick-to: 6.7 Change-Id: I31142399385521d973b2ed3789745569e44d5d63 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMetaObject: revert adding QMetaObject::indexOfEnumerator(QBAV)Ahmad Samir2024-01-301-5/+0
| | | | | | | | | | | | | | | | This partially reverts 4ecbe42ff44ace881ed4962744e9cd6c8fa65dab . The discussion is still ongoing to decide whether the new overload should take a QBAV or QAnySV. See https://codereview.qt-project.org/c/qt/qtbase/+/514588 for the details. For the time being remove the new overload from the API so that this can be backported to 6.7 (while keeping both dev and 6.7 in sync to ease future backports). Pick-to: 6.7 Change-Id: I4a279653d1941faeafd95dde7a8c741009c00c72 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QObject: Let moveToThread return succcess stateChristian Ehrlicher2024-01-241-0/+5
| | | | | | | | | | | | | | | Add bool QObjectPrivate::moveToThread() which returns the success state of the attempt to move the object to the new thread. For Qt7 the public signature of QObject::moveToThread() should be changed to directly return this value. [ChangeLog][QtCore][QObject] QObject::moveToThread() now returns a boolean success state. Pick-to: 6.7 Change-Id: I8441c8155a76b804b473ab9c45c2be6840ef1677 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Make public QLocale's constant for the two-digit-year baseIvan Solovev2024-01-221-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The private QLocale::FirstTwoDigitYear constant, which is used as a default value for the parameters in some methods, causes troubles for Qt for Python Team, because they need to use the default values in the binding code. It also potentially create some inconveniences for the users who want to write functions wrapping these methods. The name is also confusing, because, when read out of context, it implies that there might be SecondTwoDigitYear, etc... Rename QLocale::FirstTwoDigitYear to QLocale::DefaultTwoDigitBaseYear and make it public. Now when the constant is public, we can use it in QDate, instead of introducing another constant, so do that. The qdatetime.h header already includes qlocale.h via qcalendar.h, but, rather than relying on this transitive include, add it explicitly. As pointed out by Thiago [1], the static constexpr members of exported classes need out-of-line definitions, so add such definition to qlocale.cpp. Amends 41f84f3ddb780ec751e3fc706dd242fc4a99de7a Found in 6.7 API review. [1]: https://lists.qt-project.org/pipermail/development/2024-January/044888.html Pick-to: 6.7 Change-Id: Ib3c6f1d5b181968bf311fd0435173e025a369865 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QByteArray: inline QByteArray::indexOf() and use a char overloadThiago Macieira2023-12-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QByteArray::indexOf() had the best implementation of the two *because* it was out-of-line, in qbytearray.cpp. The compiler could thus see the body of the QtPrivate::findByteArray() function and inline it, with constant-propagation, so only findCharHelper() was expanded and we had a fast path towards memchr(). On the other hand, QByteArrayView::indexOf() was inline, so the compiler emitted the call to QtPrivate::findByteArray() in user code, causing the full function to be executed. We fix that by adding a char overload for QtPrivate::findByteArray() and lastIndexOf(), so we get to memchr() more quickly. Also, inline QByteArray::indexOf() and lastIndexOf(). Before: QByteArray::indexOf(): 8.83287376 nsecs per iteration 22.01766832 CPU cycles per iteration, 2.49 GHz 62.00000330 instructions per iteration, 2.816 instr/cycle 21.00000281 branch instructions per iteration, 2.38 G/sec QByteArrayView::indexOf(): 9.64034694 nsecs per iteration 24.03001151 CPU cycles per iteration, 2.49 GHz 68.00000355 instructions per iteration, 2.830 instr/cycle 23.00000306 branch instructions per iteration, 2.39 G/sec After (same result for both, requires recompilation): 8.83207052 nsecs per iteration 22.01568546 CPU cycles per iteration, 2.49 GHz 60.00000331 instructions per iteration, 2.725 instr/cycle 21.00000281 branch instructions per iteration, 2.38 G/sec The inlining appears to have cut 2 instructions, but the effect is not measurable in this benchmark (the entire code is in cache and the Branch Predictor is probably primed). Fixes: QTBUG-119750 Change-Id: Ica7a43f6147b49c187ccfffd179e1cb4b306fc62 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QObject: re-add the nameless qt_qFindChildren_helper to restore BCThiago Macieira2023-12-211-0/+6
| | | | | | | | | | | | | | | | | | Amends e608bc019232f6956c4520be1a6103a1845c6991 by adding the implementation of this method whose implementation got accidentally removed (because it became unused). It's added in removed_api.cpp because, as the commit said, the cost for creating an empty QAnyStringView is practically nil. It's not zero on Windows, because the replacement function has five parameters, so the last (the options) is passed on the stack. But that is not enough of a justification to keep separate functions. Pick-to: 6.7 Fixes: QTBUG-120309 Change-Id: I6e2677aad2ab45759db2fffd17a29b4ec7728426 Reviewed-by: Rym Bouabid <rym.bouabid@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Give the caller control over the century used for two-digit datesEdward Welbourne2023-12-081-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The twentieth century is now some way behind us, so using its years when parsing a date-time format that only provides the last two digits is increasingly likely to produce unwelcome results. Most such formats are saved by the "redundant" presence of a day-of-week field but, for those that are not (notably including ASN.1 date fields), there is a need to provide some way to over-ride the twentieth century default. Allow the caller to pass a base year to the fromString() methods, of QDate and QDateTime, and to QLocale's toDate() and toDateTime(), that indicates the first of 100 consecutive years, among which the two digits given can select a year. Add some test-cases to exercise the new API. [ChangeLog][QtCore][QDate] When fromString() has only a two-digit year to go on, it is now possible to set the start-year of the century within which this selects. [ChangeLog][QtCore][QDateTime] When fromString() has only a two-digit year to go on, it is now possible to set the start-year of the century within which this selects. [ChangeLog][QtCore][QLocale] When toDate() or toDateTime() has only a two-digit year to go on, it is now possible to set the start-year of the century within which this selects. Fixes: QTBUG-46843 Change-Id: Ieb312ee9e0b80557a15edcb0e6d75a57b10d7a62 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QBitArray: replace the member operator~ with a hidden friendThiago Macieira2023-12-071-0/+7
| | | | | | | | | | | | | | Which takes the array to be inverted by value, so we get free move semantics and allowing us to perform the negation in-place. [ChangeLog][Potentially Source-Incompatible Changes] The bitwise AND, OR, XOR, and NOT operator functions on QBitArray are now hidden friends. This may cause source-incompatibility in unusual coding styles (like 'array.operator~()') or with classes that have a casting 'operator QBitArray()'. Change-Id: I85b3fc2dd45c4693be13fffd1795ba1fbaf23769 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QTimeZone: use new comparison helper macrosIvan Solovev2023-11-281-0/+12
| | | | | | | | | | | | | The class had operator==() and operator!=() defined as public member functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of these methods and replace them with hidden friends. Extend unit-tests by using the helper functions from QTestPrivate. Task-number: QTBUG-104111 Change-Id: Ib9ca613005e2f1521dea5e3cd9e2baa0b47fede4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QDateTime: use new comparison helper macrosIvan Solovev2023-11-281-0/+5
| | | | | | | | | The unit-tests were already ported to the new comparison helper functions from QTestPrivate. Task-number: QTBUG-104111 Change-Id: I95fccb33433b3bbf1167545e347a271140727f23 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QCborStreamReader: fix API mistake: lastError() wasn't constThiago Macieira2023-11-241-0/+7
| | | | | | | | [ChangeLog][QtCore][QCborStreamReader] Fixed lastError() not being declared as a const member. Change-Id: Ib1d2fc7100134f7597cdfffd174a8401b43576d4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QObject: port findChild/ren() to QAnyStringViewRym Bouabid2023-11-221-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Change the object's name type in QObject::findChild/ren() to QAnyStringView, because they are only used for comparison against objectName property. qt_qFindChild{,ren}_helper() functions taking an objectname as QString have to stay in the ABI as they were exported in inline methods before Qt 6.7. Unlike QString, constructing a null QAnyStringView doesn't involve any code-size overhead. So, get rid of the split in qt_qFindChildren_helper that was introduced for QString. Remove unneeded qt_qFindChildren_with_name helper function and qt_qFindChildren_helper overload without a name. findChildren(options) method used to call qt_qFindChildren_helper overload. Instead, call findChildren overload with name argument and pass QAnyStringView{} as the object name. [ChangeLog][QtCore][QObject] Ported QObject::findChild/ren() and their helper functions to QAnyStringView. Task-number: QTBUG-103986 Change-Id: I68bda0e581f984ae48b7581ad86cc1b95008c1b0 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QMetaObject: add indexOfEnumerator(QBAV) overloadAhmad Samir2023-10-271-0/+6
| | | | | | | | | | | | | | | | | And remove the indexOfEnumerator(const char *) overload. Taking by view so that it works with string data that isn't necessarily null-terminated (e.g. a sliced() or chopped() view). QMetaObjectPrivate::indexOfEnumerator needs to be a member function because it usess a private QMetaEnum constructor (QMetaObjectPrivate is a friend of QMetaEnum). [ChangeLog][QtCore][QMetaObject] Added indexOfEnumerator(QByteArrayView) overload. And deprecated indexOfEnumerator(const char *) overload. Change-Id: Ie2f4f1a9af69373c19a5d7bd92499544e95e9289 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QString/QByteArray: add lvalue and rvalue overloads of left/mid/rightThiago Macieira2023-10-251-0/+70
| | | | | | | | | | | | The first/last/sliced API may be what we suggest users use, but the vast majority of the installed codebase uses left/mid/right because they've been available since time immemorial. An additional benefit of this is to make left() and right() available as inline methods. Change-Id: Ifeb6206a9fa04424964bfffd1788383817ed906c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QString/QBA: add lvalue and rvalue overloads to first/last/sliced/choppedThiago Macieira2023-10-251-0/+32
| | | | | | | | | | | | Those ought to have been the original implementation, when they were added in commit 38096a3d7040edac4f769270d2402ff4e39d7694, for Qt 6.0. Because these classes are exported, we need to provide the previous only implementations for MSVC. All other compilers would provide inline or emit local, out-of-line copies. Change-Id: Ifeb6206a9fa04424964bfffd178836a2ae56157d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add support for containers > 4 Gi elements in QDataStreamØystein Heskestad2023-10-231-0/+50
| | | | | | | | | | | | The format is changed from 6.7 to support more than UINT32_MAX - 1 elements. The format used to have a quint32 size. Now if the size is larger or equal to 0xfffffffe (2^32 -2) the old size is an extend value 0xfffffffe followed by one quint64 with the actual value. The 32 bit size with all bits set is still used as null value. Fixes: QTBUG-105034 Change-Id: I62188be170fe779022ad58ab84a54b1eaf46e5d9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime: disambiguate times in a zone transitionEdward Welbourne2023-10-191-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, requesting a time that got repeated - on the given date, due to a fall-back transition - would get one of the two repeats, giving the caller (no hint that there was a choice and) no way to select the other. Add a flags parameter that captures the available ways to resolve such ambiguity or select a suitable time near a gap. Add such a parameter to relevant QDateTime methods, including constructors, to enable callers to indicate their preference in the same way. This replaces DST-hint parameters in various internal functions, including QTimeZonePrivate's dataForLocalTime(). Adapted tst_QDateTime to test the new feature. Adapt to gap-times no longer being invalid (by default; or, when they are, no longer having a useful toMSecsSinceEpoch() value). Instead, they don't match what was asked for. Amend documentation to reflect that. Most of the code change for this is to QDTParser and QDTEdit. [ChangeLog][QtCore][QDateTime] Added a TransitionResolution parameter to various QDateTime methods to enable the caller to indicate, when the indicated datetime falls in a time-zone transition, which side of the transition to fall or whether to produce an invalid result. [ChangeLog][QtCore][Possibly Significant Behavior Change] When QDateTime is instantiated for a combination of date and time that was skipped, by local time or a time-zone, for example during a spring-forward DST transition, the result is no longer marked invalid. Whether the selected nearby date-time is before or after the skipped interval may have changed on some platforms; unless overridden by an explicit TransitionResolution, it is now a date-time as long after the previous day's noon as a naive reading of the requested date and time would expect. This was the prior behavior at least on Linux. Fixes: QTBUG-79923 Change-Id: I11d5339abef9e7125c4e0dc95a09a7cd4f169dab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* JNI: move private QJniObject helpers out of the public headerVolker Hilsheimer2023-09-271-0/+21
| | | | | | | | | | | | | | Functions that are not called by any of the inline code don't have to be in the public header. Move them as static functions into the translation unit. Remove some useless wrappers in the private, and move the code for private and static functions together. Some private helpers have to stay in the ABI as they used to be called by at least one public inline function up to Qt 6.6. Remove them from the API using QT_CORE_REMOVED_SINCE. Change-Id: I7eb7b2ba994dfda9de11e2d090a70842dad17247 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* invokeMethod: enable passing parameters to overload taking functorsMårten Nordheim2023-08-241-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | This was missing for a while, and there is nothing fundamentally missing for it to work. With the more recent work around slot objects and invokeMethod in general, it is a good time to add support for this. In this patch, when connecting to a functor, it automatically deduces the overload to call based on the arguments passed to invokeMethod. Sharing code with QObject::connect could be done, but they have a key difference that makes it harder: With signal emissions we throw away trailing arguments that are not used: i.e. `signal(int, int)` can be connected to `slot(int)` or `slot()`. With invokeMethod that's not a thing. So we will need a way to toggle that behavior during resolution. [ChangeLog][QtCore][QMetaObject] Added support for passing parameters to the overload of QMetaObject::invokeMethod that takes a functor. These new overloads must have the return-value passed through qReturnArg(). Change-Id: If4fcbb75515b19e72fab80115c109efa37e6626e Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Give QLocale's name() and bcp47Name() separator parametersEdward Welbourne2023-08-181-0/+10
| | | | | | | | | | | | | Previously name() has always used underscore and bcp47Name() dash; let the user chose which one best fits their needs. [ChangeLog][QtCore][QLocale] QLocale's name() and bcp47Name() now let the caller chose what separator to use between the tags making up the name, where there is more than one. Change-Id: Ia689e6a3fb581b42905e7fb1ae7a7b688244d267 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Give QLocale::uiLanguages() a separator parameterEdward Welbourne2023-08-161-0/+7
| | | | | | | | | | | | | | | | | | | It has always returned dash-joined forms of the locale names, and callers who need an underscore-joined form have been obliged to replace('-', '_') before using them. Given that everything it adds to the list comes from QLocaleId methods that accept a separator, it's trivial to let it offer the same choice to its callers and save them this hassle. Amended code in QTranslater and QMimeType to save them that hassle. [ChangeLog][CoreLib][QLocale] QLocale::uiLanguages() now lets the caller choose what separator to use between the tags that make up each locale-identifier in the list returned. Change-Id: I91fcd0b988d9a64e0e9ad9e851f6cb8c1be8ae50 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>