summaryrefslogtreecommitdiffstats
path: root/src/corelib/compat/removed_api.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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>
* QUrl: Add QUrl::fromEncoded(QByteArrayView) overloadAhmad Samir2023-06-081-0/+15
| | | | | | | | | | | Copy \note about backwards compatibility from QMessageAuthenticationCode (with minor changes). [ChangeLog][QtCore][QByteArray] Added QUrl::fromEncoded(QByteArrayView) overload. Change-Id: I8a190db2d50467e6191caf0abfe975b8fc656eb4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QObject: add setProperty() overload taking rvalue QVariantMarc Mutz2023-05-311-0/+2
| | | | | | | | | | | | | | | | Instead of duplicating the long-ish implementation, simply pass the variant as pointers to const and mutable, and implement a runtime version of std::forward. [ChangeLog][QtCore][QObject] Added setProperty() overload taking an rvalue QVariant. Fixes: QTBUG-113281 Task-number: QTBUG-112762 Change-Id: Ifdc8f626ad5db138073474c3bd95ec7308c4396b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QSemaphore: add QDeadlineTimer APIThiago Macieira2023-05-161-0/+1
| | | | | | | | This removes the last use of QtPrivate::convertToMilliseconds(). Change-Id: I6f518d59e63249ddbf43fffd1759fee2e00d36f4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
* QMutex: add QDeadlineTimer-based tryLocksThiago Macieira2023-05-111-0/+1
| | | | | | | | | | | | | | This simplifies the code greatly, because we don't need to use QtPrivate::convertToMilliseconds any more, as QDeadlineTimer has nanosecond precision. Internally it becomes simpler too because lockInternal was already using QDeadlineTimer. I just had to use the parameter instead and update the two non-futex implementations to take it again. This may even be fixing a mistake in case sem_timedwait(2) got interrupted. Change-Id: I6f518d59e63249ddbf43fffd1759fed9f50b3606 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QReadWriteLock: inline the lockForXxx functionsThiago Macieira2023-05-111-0/+4
| | | | | | | | We can now do that because tryLockForXxxx(-1) is fast for the uncontended case too. Change-Id: I3d728c4197df49169066fffd1756ddd06caf7b52 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QReadWriteLock: remove the untimed tryLockForXxxx functionsThiago Macieira2023-05-111-0/+11
| | | | | | | | | | They're unnecessary now because the timed function is fast enough. Note: the default argument will move to the QDeadlineTimer functions before the Qt 6.6 release. Change-Id: I3d728c4197df49169066fffd1756ddc0e4f796d3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Take move-only functions for the threadpoolAllan Sandfeld Jensen2023-05-041-0/+39
| | | | | | | | | | | | We never copy the function so only need it to movable. Moves the functions to templates using the new QRunnable create version. [ChangeLog][QtCore][QThreadPool] Methods taking callable functions, can now take move-only lambdas. Fixes: QTBUG-112302 Change-Id: I2cb200f0abcf7e0fdbef0457fe2a6176764ad93d Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QXmlStreamAttributes: port value()/hasAttribute() to QAnyStringViewMarc Mutz2023-04-251-0/+28
| | | | | | | | | | [ChangeLog][QtCore][QXmlStreamAttributes] Ported value() and hasAttribute() to QAnyStringView. Change-Id: I771b9cede1d581d3f1142246e7a25c36bcc850d6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Create any callable using QRunnable::createAllan Sandfeld Jensen2023-04-041-0/+7
| | | | | | | | | | | | The overhead of making new custom classes appears to be less than constructing a generic std::function. [ChangeLog][QtCore][QRunnable] QRunnable::create can now take non-copyable functions as argument. Task-number: QTBUG-112302 Change-Id: Ied870f13ca6c7eaa14ed6eff9c4e676c7b73881c Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QMessageAuthenticationCode: port to QByteArrayView [3/3]: static hash()Marc Mutz2023-03-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | The class is not used frequently enough to warrant the overhead of a Q_WEAK_ QByteArray overload to fix the SiC Type A for users that pass objects that implicitly convert to QByteArray, esp. since we'd need _four_ overloads to handle the two byte array arguments here, and still cause ambiguities, because there's only one level of "weakness" in Q_WEAK_OVERLOAD, but we'd need two. QCryptographicHash::hash() also doesn't have it. [ChangeLog][QtCore][QMessageAuthenticationCode] The constructor, setKey(), addData() methods as well as the static hash() function take arguments by QByteArrayView instead of QByteArray now. [ChangeLog][Potentially Source-Incompatible Changes] More APIs now take QByteArrayView instead of QByteArray. You will now get a compile error when your code passes to such functions objects that implicitly convert to QByteArray, but not QByteArrayView. Wrapping such arguments in QByteArray{~~~} to make the cast explicit is a backwards-compatible way to avoid this problem. Fixes: QTBUG-111676 Change-Id: Iaff832df3b315ca2eee7bff93720b6681182036f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QMessageAuthenticationCode: port to QByteArrayView [2/3]: addData()Marc Mutz2023-03-171-0/+5
| | | | | | | | | | | | | | | | | | | | | The class is not used frequently enough to warrant the overhead of a Q_WEAK_ QByteArray overload to fix the SiC Type A for users that pass objects that implicitly convert to QByteArray. QCryptographicHash also doesn't have it. Also mark addData() noexcept. Now that it takes a view instead of an owning container, it only calls other noexcept functions. Make the new overload carry actual documentation instead of just \overload. ChangeLog will be on patch [3/3]. Task-number: QTBUG-111676 Task-number: QTBUG-111688 Change-Id: Ie6447bf54d7d442b1a76761bc0f28f868c08ef09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QMessageAuthenticationCode: port to QByteArrayView [1/3]: ctor/setKey()Marc Mutz2023-03-171-0/+11
| | | | | | | | | | | | | | | | | The class is not used frequently enough to warrant the overhead of a Q_WEAK_ QByteArray overload to fix the SiC Type A for users that pass objects that implicitly convert to QByteArray. QCryptographicHash also doesn't have it. Also mark setKey() noexcept. Now that it takes a view instead of an owning container, it only calls other noexcept functions. ChangeLog will be on patch [3/3]. Task-number: QTBUG-111676 Task-number: QTBUG-111688 Change-Id: Ic2321d0d41ce8eb4d0390889f28b3fd4bd9af103 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QBasicTimer: replace new qint64 overloads with chrono onesMarc Mutz2023-03-021-11/+1
| | | | | | | | | | | | | | | Found in API review. As per "chrono first" initiative[1], implement the int overload via the chrono one, not vice versa [1] https://lists.qt-project.org/pipermail/development/2023-January/043563.html Pick-to: 6.5 Change-Id: I65fe7039ad8ae5f9eb21d9c59a46b9c5c152fac3 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QString: port toUcs4_helper() to char16_t/char32_tMarc Mutz2023-01-231-0/+16
| | | | | | | | | | | | | | This gets rid of 50% of the casts required to call the function, and removes the last QtCore QStringView(ushort*) user. As a drive-by, replace an (allowed, but) fishy &str[0] with str.data(), the mutable overload of which has been available since C++17. Task-number: QTBUG-110403 Change-Id: Iad494025b61c53d991e59cc73198bb014a422a93 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* IPC: add native key support to QSharedMemoryThiago Macieira2023-01-221-0/+9
| | | | | | | | | | | | | And deprecate the non-native key support API. Qt 7 may not even store the old, non-native key. Documentation in a new commit, when the dust settles. Drive-by updates to the tst_QSharedMemory::attach row names, to fix grammar and remove spaces and apostrophe. Change-Id: I12a088d1ae424825abd3fffd171d3025c77f94d2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtCore removed_api.cpp: fix missing instruction comment in 6.5 blockMarc Mutz2023-01-201-0/+4
| | | | | | | | | | Thanks to Ahmad for noting. Amends 6bc227a06a0d1392d220aa79ddb1cdc145d4f76e. Pick-to: 6.5 Change-Id: Ie6191bfc21d69f88a9a135f0d5f6b4fa8b09e8ad Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QXmlStreamReader: fix spelling of PrivateConsructorTagMarc Mutz2023-01-181-1/+1
| | | | | | | | Found in API review. Pick-to: 6.5 Change-Id: I347ae3cc6a51095dddaba617adc2f63612578ef3 Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
* QXmlStreamWriter: port API from QString to QAnyStringViewMate Barany2022-12-101-0/+96
| | | | | | | | | | | | | | | QXmlStreamWriter is basically a fancy way to append to a string, not saving any of them individually, so this API is a perfect candidate for replacing all of the QStrings with QAnyStringViews. [ChangeLog][QtCore][QXmlStreamWriter] Ported API to QAnyStringView (was: QString). Fixes: QTBUG-103302 Change-Id: I9fb1f2d5793cf9f35d468c46c0127d3ebd57f3dd Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QXmlStreamWriter: prepare for port to QAnyStringViewMarc Mutz2022-12-101-0/+11
| | | | | | | | | | | | | | | | | | | | | The UTF-8 support in Qt is still lacking, so QUtf8StringView doesn't, yet, have the likes of contains(), endsWith(), etc that the existing QString code uses in Q_ASSERTs. Provide free functions that work for UTF-8 haystacks and ASCII needles by falling back to QByteArrayView or QLatin1StringView. Also break a replace() use into a series of indexOf() + chunked write(). This is rather expensive for QString, so port the writeCDATA() function that uses this to QAnyStringView already, ahead of the bulk of the changes in Mate's follow-up patch. Task-number: QTBUG-103302 Change-Id: Ic66261740817ede2600b78a383cf667a31df7bfc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
* qfloat16: remove the metatype dependencyThiago Macieira2022-11-281-0/+1
| | | | | | | | | | | | | | | | This macro usage is not correct. I don't know what it is for because the documentation next to it describes how to use it, not why one should use it. Anyway, it's most definitely the incorrect solution for whatever problem there may have been, so remove. I also couldn't move it to removed_api.cpp. If I do, then the QMetaTypeInterface created for qfloat16 misses the pointers to QDataStream. I'm not sure why... I think it's because the operator>> and operator<< become ambiguous, so the SFINAE to check if they exist gives up. Change-Id: I3d74c753055744deb8acfffd17247e1d2317f11c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix build with -no-feature-settingsAlexey Rochev2022-11-171-0/+3
| | | | | | | Pick-to: 6.4 Change-Id: Ia79e5e616a1c35da299c00766e960789c7b60695 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QString: mark inline to{U,}LongLong() for inlining in Qt 7Thiago Macieira2022-11-151-0/+3
| | | | | | | | | | | | The original implementation of the toIntegral_helper() called these two functions, before we added the out-of-line non-template toIntegral_helper() overloads taking QStringView for Qt 5.15 in commit f1cbc3c9d24024b6bdd8d0346de9d7e548133459. They should have been inlined in Qt 6.0, but no one noticed this. Change-Id: Id8e48e8f498c4a029619fffd172795aaba2d815b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Fix build with -no-feature-xmlstreamreaderAlexey Rochev2022-11-021-0/+4
| | | | | Change-Id: Ia55d0d1640f08fbff3e0bb5fef0cde261acdc4bd Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Rename the header qenvironmentvariables.h -> qtenvironmentvariables.hSona Kurazyan2022-09-301-1/+1
| | | | | | Change-Id: I8153c856c2cd93ec6932cd7dd5e9d7273d5712dd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QFuture: fix handling of cancelled continuation chainSona Kurazyan2022-09-211-18/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support cancellation of continuations attached via the parent future, for each future returned by a continuation we store a pointer to its parent (i.e. future the continuation is attached to). Later, before executing a continuation, we go through chain of parents and check if any of them is cancelled. However, if one of the parents is destroyed while the chain is executing, the next continuations' parent pointers will become invalid. So storing the parent pointers isn't safe. This commit changes the logic of handling the cancelled continuation chain in the following way: - Instead of storing a parent pointer in the continuation future's data, we do the opposite: we store a pointer to continuation's future in the parent. - When a future is cancelled, we mark all continuation futures in the chain with a flag indicating that the chain is cancelled. - To guarantee that the pointers to continuation future's data don't become invalid, we clean the continuation (that stores a copy of its future's data and keeps it alive) only when the associated promise is destructed, instead of cleaning it after the continuation is run. Fixes: QTBUG-105182 Fixes: QTBUG-106083 Pick-to: 6.2 6.3 6.4 Change-Id: I48afa98152672c0fc737112be4ca3b1b42f6ed30 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port QDir to qsizetype [3/3]: APIMarc Mutz2022-09-071-0/+14
| | | | | | | | | | | | | | | | [ChangeLog][QtCore][QDir] The count() function now returns, and the indexing operator now takes, qsizetype (was: uint and int, respectively). [ChangeLog][Potentially Source-Incompatible Changes][QDir] The count() function now returns qsizetype (was: uint). Task-number: QTBUG-103525 Change-Id: Ib84af36f6a95d9a0d1090a2d6fb973a4e363550c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QtCore: removed_api.cpp: fix orderingMarc Mutz2022-09-071-2/+2
| | | | | | | | | | BA sorts before BU... Amends da12a40b8b2c2d212412a9db6d7971dc43bce6e6. Change-Id: I11ffc89e901b3ef0eab2c6a422125dc3a77dd66e Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Migrate QBasicTimer from int to qint64Konrad Kujawa2022-08-301-0/+12
| | | | | | | QBasicTimer::start() now accepts qint64 instead of int. Change-Id: Iba3f394b6c20daf762f1add5a9eed22c8a67c802 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QBuffer: fix the setData() API re: int/qsizetypeMarc Mutz2022-08-201-0/+2
| | | | | | | | | | | The setData(ptr, n) overload was still taking the size as int. Widen it. Task-number: QTBUG-103525 Change-Id: If1d6d6404d62bbae5e0defea9a2115648c1fd5da Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* qputenv: port to QByteArrayViewMarc Mutz2022-08-061-0/+7
| | | | | | | | | | | | | | | | | | | | The vast majority of in-tree users pass simple and short C string literals as the value. By porting to QByteArrayView, we document that we'll accept non-NUL-terminated data, and do the NUL-termination internally, using SSO'ed std::string, saving memory allocations in the common case of short strings. I didn't bother to check which direction std::string takes for nullptrs these days (there was a change accepted in that area for C++20 or 23), so play it safe and protect against them. Follow-up to Task-number: QTBUG-105302 Change-Id: I2369acc62f1d5cbc26135396cfe0602d8c75300c Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QVariant: update constructors for trivially copyable typesThiago Macieira2022-07-271-0/+20
| | | | | | | | | | | | | Make them all noexcept and ensure they are all passed by value. Unfortunately for QRectF and QLineF, they're too big when qreal==double, so QVariant needs to allocate memory itself. Strictly speaking, they're too big for passing by value too, but the codegen is identical, so we may as well. For Qt 7, enlarging QVariant::Private would be a good idea. Change-Id: I3859764fed084846bcb0fffd17044ac379b3c1d2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
* QByteArray: inline QByteArray::isNull()Thiago Macieira2022-07-271-0/+2
| | | | | | | | | | | | | | | | | Keeping it out-of-line is unnecessary and has been since 5.0. In Qt 4.x, it was necessary to compare to the shared_null, which for QByteArray was a static variable. The one for QString has always been inline because the shared null was a static member of QString (in Qt 3, QString::null was a QString variable). See: https://code.qt.io/cgit/qt/qt.git/tree/src/corelib/tools/qbytearray.cpp#n3249 https://code.qt.io/cgit/qt/qt.git/tree/src/corelib/tools/qstring.h#n505 Pick-to: 6.4 Change-Id: I89c4eb48af38408daa7cfffd16fdd7696520f1b6 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QMetaType: add registerType() and qRegisterMetaType(QMetaType)Thiago Macieira2022-07-261-0/+8
| | | | | | | | | | | | | | | | | | | | | | | This also rewrites QMetaType::id() on top of the helper, with the benefit of calling a member static function, so QMetaType doesn't need to be spilled onto the stack. In some upcoming changes I need to ensure that QMetaTypes are registered so they can be found by name and I'd like to have a dedicated function name for that, instead of calling .id(). Since I needed to add docs for the new function, I've updated for the old one too. [ChangeLog][QMetaType] Added QMetaType::registerType() and an overload of qRegisterMetaType() taking QMetaType (the two functions do the same thing). These two functions ensure a given QMetaType is registered with the Qt global registry, so they can be found by name later. Using qRegisterMetaType<T>() also accomplishes the same thing, but is slightly better for completely generic code because it will avoid emitting the registration for built-in types. Change-Id: I3859764fed084846bcb0fffd170351d606034c22 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QCollator: port compare(ptr, n, ptr, n) to qsizetypeMarc Mutz2022-07-201-0/+2
| | | | | | | | | | | | | | | | | | | While the function is inline, the class is exported wholesale, so the function forms part of the ABI on Windows (but not Unix), so we must overload, can't replace. To avoid ambiguities where users pass different integer types as the lengths of the LHS and RHS strings, QT_REMOVED_SINCE the old overload. Since the removed function has an inline definition, it suffices to just include the header into the corresponding QT_REMOVED_SINCE section of the removed_api.cpp file, to elegantly solve the BiC problem only for those platforms (MSVC) where it matters. Pick-to: 6.4 Task-number: QTBUG-103531 Change-Id: I74d446f08fcd6247a2ec44575b8afef8d014c3b5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port QXmlStremReader to QAnyStringViewSona Kurazyan2022-07-121-0/+35
| | | | | | | | | | | | | | | | Port the constructor and addData() method to QAnyStringView, but keep the overloads taking a QByteArray to avoid extra copies when actual QByteArray is passed. These overlaods need to be Q_WEAK_OVERLOADs, to avoid ambiguities (e.g. for const char * arguments). Additionally, add a test to make sure the patch doesn't break parsing from a QLatin1StringView input. [ChangeLog][QtCore][QXmlStremReader] Added constructor and addData() overloads taking QAnyStringView. Change-Id: I0efaab82a2123271c88407e380f3c67d1099a4a6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Move QFutureInterfaceBase::cleanContinuation() to removed_apiSona Kurazyan2022-06-221-0/+17
| | | | | | | | | | This method isn't used anymore, but we can't remove it entirely for BC reasons, because it was called from inline code. Pick-to: 6.4 Change-Id: I9183c666c466030787ac7c2386706b50abf23eaa Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Long live QT_INLINE_SINCE!Marc Mutz2022-06-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have now had several requests for inlining previously-exported member functions, but no standard mechanism to effect it. As QT_REMOVED_SINCE has shown, there is great value in having such a standard mechanism, so here is one. With this change, to inline a previously exported (member) function, simply - mark the declaration with QT_<MODULE>_INLINE_SINCE - move the definition into the header file (outside the class), - wrap it in QT_<MODULE>_INLINE_IMPL_SINCE - #include the header into the module's removed_api.cpp Just including the header into removed_api.cpp is enough, so you may want to add a comment: #include "header.h" // uses QT_<MODULE>_INLINE_SINCE The effect is as follows: - A TU in a _different_ library will see an inline declaration, followed by the definition, and so it will see a normal inline function. - A TU in the same library will, however, see a non-inline declaration, to avoid the ODR violation that at least GCC/ld are able to detect. - When QT_<MODULE>_BUILD_REMOVED_API is in effect, the TU will also see the definition, which is the same setup as before the change, except in a different TU, and therefore export the member. - When, OTOH, QT_<MODULE>_BUILD_REMOVED_API is _not_ in effect, the TU will see no declaration, assuming (correctly), that the definition will be supplied by a different TU. This is, of course, an ODR violation, but not worse than what we do elsewhere, as the definitions differ only between library and user. The function is inline only for the users of the library, not the library itself, which will still see the function as non-inline. If inlining is critical within the library, too, the existing function should call a new inline function, and calls in the same library should be changed to call the new inline function instead. Use the new mechanism to inline the QLocale ctor we intended to inline for 6.3, but couldn't, because we hadn't found the magic incantation, yet. Thiago found it a few weeks later, and this is what this patch is based on. Fixes: QTBUG-100452 Pick-to: 6.4 Change-Id: Ia0030cddc64b6b92edfed860170d5204aa74b953 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qHash: pass QByteArrayView to qHash() by valueThiago Macieira2022-06-151-0/+12
| | | | | | | | | | | | | The QBAV one should pass the parameter by value, like QStringView. And now that we have it, the non-View one should call the View one in an inline function, like we already do for QString. The extra, defaulted parameter is there only so we get a different signature in the new inline function compared to the removed one. Pick-to: 6.4 Change-Id: If05aeeb7176e4f13af9afffd16e7f08062b1dc86 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QtCore: Replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-03-261-3/+3
| | | | | | | Task-number: QTBUG-98434 Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QSettings: port API from QString to QAnyStringView keysMarc Mutz2022-03-231-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the public interface ported to QAnyStringView, we can now internally optimize memory allocations _in a central place_ (e.g. by returning std::u16string or QVarLengthArray<QChar> from normalizeKey() instead of QString). But first we needed to get rid of all the unwarranted allocations in user code. Effects on Linux AMD64 stripped C++20 release builds: GCC 11.2 libstdc++ (TEXT -= 6.5%): text data bss dec hex filename 635148 10992 2824 648964 9e704 tst_qsettings-01-baseline 593691 10992 2824 607507 94513 tst_qsettings-02-qanystringview Clang 10.0.0 libc++ (TEXT -= 11.6%(!)): text data bss dec hex filename 790336 10640 2832 803808 c43e0 tst_qsettings-01-baseline 698572 10640 2832 712044 add6c tst_qsettings-02-qanystringview That's the beauty of QAnyStringView: transparently reducing temporary QString creation; and the simplest code is also the most efficient. [ChangeLog][QtCore][QSettings] Keys can now be passed as QAnyStringView (was: QString). The most efficient way to pass literal keys is now "key"_L1, the backwards-compatible way is QStringLiteral("key"). Fixes: QTBUG-101390 Change-Id: I510fb4ce17ef109dac7c9cdc5d90ede0d1a9db5f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QObject: port setObjectName() to QAnyStringViewMarc Mutz2022-03-151-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... while keeping the QString overload for users that pass actual QStrings (e.g. QStringLiteral). However, QString and QAnyStringView cannot be overloaded (they're ambiguous for most arguments), so we need to make one of them a Q_WEAK_OVERLOAD. Normally, we'd make the new function weak and keep the old function as-is, but, here, that would be beside the point, because all callers would continue to resolve to the QString overload, and nothing would call the QAnyStringView one. So we really want the old function to be the Q_WEAK_OVERLOAD, so that the QString overload is only selected when actual QStrings are passed. That means we need to leave the old function in a compat build (compiled in, but not visible in the public header). Since Q_WEAK_OVERLOADs cannot be (easily) exported (they're templates), make it call a private function (which can be, and is, exported). Reviewers may questions whether one can overload setObjectName() and template <typename = void> setObjectName() The answer is that we can, because templates mangle differently from normal functions. We can even call the template function (with explicit template arguments), as seen in removed_api.cpp. This adapts the interface of the function to how most users use it: They pass QLatin1String or just const char[]. Only very few passed QStringLiteral, which, ignoring that fact that it produces a ton of code for the temporary QString's destructor that's never executed, would have been, and continues to be, the optimal way of passing data, modulo plugin bugs (QTBUG-51602, QTBUG-49061). [ChangeLog][QtCore][QObject] Added setObjectName() overload taking QAnyStringView. Fixes: QTBUG-101393 Change-Id: I1243545614754b4978d4c8641460980b6b293c1a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QDataStream: make qfloat16 streaming a non-memberMarc Mutz2022-03-141-0/+17
| | | | | | | | | | | | | | | | Remove the member function from the API and re-add it as a hidden friend on qfloat16, where it will be a complete type. [ChangeLog][QtCore][Potentially Souce-Incompatible Changes] The qfloat16 QDataStream operators are now hidden friends and only found by argument-dependent lookup. Previously, these were member functions on QDataStream. Fixes: QTBUG-93499 Pick-to: 6.3 Change-Id: Ib3d4df7a3fe3a9d0938f3be8b70b50fef0416262 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Move QBindingStorage methods marked for removal to removed_apiSona Kurazyan2022-02-161-0/+11
| | | | | | | | From the API review. Pick-to: 6.3 Change-Id: I676ff811a3b3d43ebcbee78ed0210d669d642947 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QUrl: Use Q_CORE_REMOVED_SINCE instead of explicit version checksIevgenii Meshcheriakov2022-02-031-0/+12
| | | | | | | | | Use Q_CORE_REMOVED_SINCE macro for fromAce()/toAce() API changes. Pick-to: 6.3 Change-Id: I057c6d648c2141929f04e4b4c4a38ba3275261ab Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocale: Use Q_CORE_REMOVED_SINCE instead of explicit version checksIevgenii Meshcheriakov2022-02-031-0/+12
| | | | | | | | | | | Use Q_CORE_REMOVED_SINCE macro for languageToCode()/codeToLanguage() API changes. Pick-to: 6.3 Change-Id: I8cc5279b1272165541c345241af49523c0f25737 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Make one QT_REMOVED_SINCE/QT_BUILD_REMOVED_API per moduleMarc Mutz2022-02-011-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A single global QT_REMOVED_SINCE will start hurting us once more modules downstream of QtCore start using the mechanism. With every use of feature, the set of code that needs to compile under QT_BUILD_REMOVED_API increases. Since we use QT_REMOVED_SINCE in situations where overloading the new and the old function don't work in general, this means all code included by any removed_api.cpp needs to be very carefully written to ensure that any calls to the overload set formed by the combination of old and new function(s) don't create ambiguities. Likewise, the set of APIs that change semantics under QT_BUILD_REMOVED_API also increases. At some point, the combination of removed_api.cpp including almost every module header and almost every header exposing source-incompatibilities when included in removed_api.cpp will make maintenance a headache. By making QT_REMOVED_SINCE and QT_BUILD_REMOVED_API per-module (QT_CORE_REMOVED_SINCE, ...), easy now that we generate the export macros using CMake, we limit the scope of this problem to the module using the feature. Downstream modules (say, QtWidgets) will now see the QtCore API like every other user, even in the widgets/compat/removed_api.cpp TU. Pick-to: 6.3 Change-Id: I177bc7bd5aa8791639f97946c98e4592d2c7f9d9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>