summaryrefslogtreecommitdiff
path: root/tests/auto/corelib/thread
Commit message (Collapse)AuthorAgeFilesLines
* QSemaphore: add QDeadlineTimer APIThiago Macieira2023-05-161-100/+0
| | | | | | | | 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>
* tst_qthreadpool: expect a warning, cleaning up the test runMarc Mutz2023-05-041-0/+8
| | | | | Change-Id: Ie9944d05e7afe5740ed10eef39c2df9281985002 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Take move-only functions for the threadpoolAllan Sandfeld Jensen2023-05-041-1/+19
| | | | | | | | | | | | 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>
* Rid of 'special case' markersAlexey Edelev2023-04-131-2/+0
| | | | | | | | | | | It's unlikely we will ever use pro2cmake at this project stage, so it doesn't make any sense to keep the 'special case' markers in the CMake scripts. Remove them and replace with TODO where needed. Change-Id: I84290c20679dabbfdec3c5937ce0428fecb3e5a7 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Long live QPromise::emplaceResult/At()!Marc Mutz2023-04-121-0/+8
| | | | | | | | | | | | And implement the rvalue overload of addResult() using it. [ChangeLog][QtCore][QPromise] Added emplaceResult() and emplaceResultAt() member functions. Fixes: QTBUG-112270 Change-Id: Id369542215a60c0818f1afa8d564498be84732e8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Deprecate QtFuture::makeReadyFuture()Ivan Solovev2023-04-051-0/+5
| | | | | | | | | | | | | | | | | | | [ChangeLog][Deprecation Notice][QtCore] The QtFuture::makeReadyFuture() method and all its specializations are deprecated since Qt 6.10. The reason for the deprecation is that the method has a makeReadyFuture(const QList<T> &) overload, which behaves differently from all other overloads (including other non-const ref QList overloads). Use QtFuture::makeReadyVoidFuture() when you need a ready void QFuture, or QtFuture::makeReadyValueFuture() when you need to propagate the input type to the returned QFuture, or QtFuture::makeReadyRangeFuture() when you need to create a multi-value future based on an input container. Fixes: QTBUG-109677 Change-Id: I55125269989df0a02840d5ddd5763ef5f1070df5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Long live QtFuture::makeReadyVoidFuture() and QtFuture::makeReadyValueFuture()Ivan Solovev2023-04-051-8/+31
| | | | | | | | | | | | | | | | [ChangeLog][QtCore][QFuture] Added QtFuture::makeReadyVoidFuture() and QtFuture::makeReadyValueFuture(). Basically, these methods behave like QtFuture::makeReadyFuture(), but QtFuture::makeReadyValueFuture() does not have a "const QList<T> &" specialization returning QFuture<T> instead of QFuture<QList<T>>, which allows it to always behave consistently. This patch also introduces usage of the new methods around qtbase. Task-number: QTBUG-109677 Change-Id: I89df8b26d82c192baad69efb5df517a8b182995f Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Long live QtFuture::makeReadyRangeFuture()Ivan Solovev2023-04-051-0/+94
| | | | | | | | | | | | | | | | [ChangeLog][QtCore][QFuture] Introduce QtFuture::makeReadyRangeFuture(). This method takes a container which has input iterators and returns a multi-value QFuture<ValueType>, where ValueType is the underlying type of the input container. This commit also replaces the usage of buggy QtFuture::makeReadyFuture(const QList<T> &) overload with the new method. Task-number: QTBUG-109677 Change-Id: I019e62eac74c643d88a65b3cc0085bc7c33bc712 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Create any callable using QRunnable::createAllan Sandfeld Jensen2023-04-041-0/+19
| | | | | | | | | | | | 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>
* tst_QThreadPool: reduce the number of infinite timeoutsMarc Mutz2023-03-311-47/+56
| | | | | | | | | | | | | | | | ... by supplying a TestThreadPool that waitsForDone() with a defined timeout in the dtor. When tests hang, this will now print an intelligible message instead of just the generic watchdog-killed-process one. Also replace all QVERIFY(waitForDone()) with the same code used in TestThreadPool's dtor and add a comment in a place we'd rather not use these tools. Pick-to: 6.5 6.2 Change-Id: Ifd2b3372eb7c7337a3ba77d003e45dcd77e23545 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QPromise: add support for addResult(braced-initializer)Marc Mutz2023-03-281-0/+15
| | | | | | | | | | | | | The usual problem, the usual fix: default the addResult() template argument to the class template argument, cf. e.g. wg21.link/p2218. [ChangeLog][QtCore][QPromise] Added support for calls to addResult() with braced initializers. Fixes: QTBUG-111826 Change-Id: I9ad7294dbcefbc5d2609ca3d9e7304dbeb8b3f41 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFutureInterface: add a warning when an existing continuation is overwrittenIvan Solovev2023-03-281-0/+30
| | | | | | | | | ... and also extend the documentation to explain this case explicitly. Fixes: QTBUG-107545 Pick-to: 6.5 6.2 Change-Id: I9414cc677b037989de60e97871485018e5c8a569 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Corelib: s/Q_OS_MAC/Q_OS_DARWIN/wg except for doc and definitionEdward Welbourne2023-03-201-1/+1
| | | | | | | | | | I got tired of being told off by the inanity 'bot for faithfully reflecting existing #if-ery in new #if-ery. Retain only the documentation and definition of the deprecated define. Change-Id: I47f47b76bd239a360f27ae5afe593dfad8746538 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QThread: add sleep(std::chrono::nanoseconds) overloadAhmad Samir2023-03-138-42/+51
| | | | | | | | | | | | | | All the other overloads are implemented using the new one. Windows change relies on the pre-check in the code review making sure it compiles. [ChangeLog][QtCore][QThread] Added sleep(std::chrono::nanoseconds) overload. Task-number: QTBUG-110059 Change-Id: I9a4f4bf09041788ec9275093b6b8d0386521e286 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTestEventLoop: add enterLoop(std::chrono::milliseconds) overloadAhmad Samir2023-03-031-6/+9
| | | | | | | Task-number: QTBUG-110059 Change-Id: Ibf1d76afd313e390103be4a22e44af7fb41ace1b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_QMutex: use constexpr variables instead of 'enum-trick'Marc Mutz2023-03-011-2/+2
| | | | | | | | | | | C++20 doesn't like arithmetic with enums anymore. While this hasn't caused immediate pain, yet, fix it pro-actively for an imminent patch. As a drive-by, fix the missing space at start of comment. Pick-to: 6.5 6.4 6.4.3 6.2 Change-Id: Id08bb227c587bc7b900c593a7b6d2655ca32eefd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-1735-72/+1
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QFuture: fix continuation cleanupIvan Solovev2023-02-151-0/+26
| | | | | | | | | | | | | | | | Not clearing the continuationData could lead to use-after-free when there is an attempt to cancel an already finished future, which belongs to an already-destroyed promise. This patch fixes it be explicitly resetting continuationData to nullptr in the clearContinuation() method, which is called from the QPromise destructor. Task-number: QTBUG-103514 Pick-to: 6.5 6.4 6.2 Change-Id: I6418b3f5ad04f2fdc13a196ae208009eaa5de367 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QPromise: improve documentation snippetIvan Solovev2023-01-091-1/+3
| | | | | | | | | | | | | | | | | The multi-thread snippet in the documentation, when copied as is, could actually crash because of the race condition between the main thread and the thread that generate results for the promise. This is fixed by explicitly calling QPromise::start(). Actually, the underlying snippet already has this call, it just was not included in the documentation. This patch modifies the documentation snippet to include calls to both QPromise::start() and QPromise::finish(). Fixes: QTBUG-109230 Pick-to: 6.5 6.4 6.2 Change-Id: Ic25f31a6b3b16ba6bc06a0b199289c8c5d50bab6 Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
* Fix crash when cancelling a QFuture that has continuation with contextSona Kurazyan2023-01-061-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | To support cancellation of continuations attached via the parent future, we store a pointer to continuation future's data in parent. This requires preserving the lifetime of continuation future's data while the parent is still alive (see 24dedaeaa1a94bfe9ade2da2a2c9aa112241b07a). This is achieved by capturing the promise in the continuation's lambda, which is only cleaned up after the parent's data is destroyed. This is already the case for continuations without context, but was overlooked for continuations with context: they transfer the ownership of the continuation promise to lambda passed to QMetaObject::invokeMethod(), which destroys the lambda's context after it's run. As a result, the continuation's promise (and data, if there are no other copies of it) is also destroyed, leaving the parent pointing to deleted continuation data. To fix this, capture a copy of continuation future's ref-counted data in the continuation's lambda. This will guarantee that the continuation data remains alive until the parent is destroyed and the continuation is cleaned up. Fixes: QTBUG-108790 Pick-to: 6.5 6.4 6.2 Change-Id: Ief4b37f31e652988d13b03499505ac65c7889226 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Long live QPromise::addResults()!Marc Mutz2022-12-301-0/+9
| | | | | | | | | | | | Makes the pre-existing QFutureInterface functionality available via the public QPromise API. [ChangeLog][QtCore][QPromise] Added addResults() to report multiple results at once. Change-Id: I18e6ef2781df422020b9022d78d6c45107b01668 Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tests: fix build with -no-feature-concurrentJohannes Kauffmann2022-11-091-1/+1
| | | | | | Pick-to: 6.2 6.4 Change-Id: I91602931bfb63e7d6659599a26e00e0bc4f854ab Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-032-52/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* tst_QAtomicInt:fetchAndAdd(): remove two duplicate data rowsEdward Welbourne2022-10-171-2/+0
| | | | | | | Change-Id: I6568399945f421a18ddb5c52c68f82474de936c5 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-111-2/+2
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QFuture: fix handling of cancelled continuation chainSona Kurazyan2022-09-211-0/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove preprocessor conditionals for chrono includeKonrad Kujawa2022-09-161-27/+2
| | | | | | | | | __has_include(<chrono>) is always true, because C++11 chrono include is required since 6.0. Pick-to: 6.4 6.3 6.2 Change-Id: I50cb92571bf4f1f86e2f3f2b5f486dd3c3f30f4a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-2337-37/+37
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Remove blacklist of tryAcquireWithTimeout on WindowsAllan Sandfeld Jensen2022-08-071-6/+0
| | | | | | | Hasn't failed on Windows in months Change-Id: Id14eaead667dfba93807592a7e0cb4da7f91f16f Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-0337-0/+111
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-287-7/+7
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* QMutex: limit moreStress test to idealThreadCount threadsVolker Hilsheimer2022-07-201-5/+7
| | | | | | | | | | | | Or the previous limit, 10. The test has a flaky and failing history, esp on macOS. Trying to provoke race conditions with more threads than we have cores has little value. Pick-to: 6.4 Change-Id: I99dd2b5a6f64faa83963c279c84fc547416f914f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QThread: Clean up bindingStatusOrList if object gets deletedFabian Kosmale2022-07-141-0/+14
| | | | | | | | | | | | Deal with the case that the object gets deleted between a call to moveToThread and the start of the thread by removing the object from the list in that case. Fixes: QTBUG-104014 Pick-to: 6.4 Change-Id: Ib249b6e8e8dfbc4d1332bb99a57fa9d3cff16465 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QThread: Initialize bindingStatus for adopted threadsFabian Kosmale2022-07-131-0/+17
| | | | | | | | | | | | | If we create a QThread from QThread::current(), we want it to have a correct value for its bindingStatus. Thus, initialize bindingStatus in the ctor of QAdoptedThread. Task-number: QTBUG-101177 Task-number: QTBUG-102403 Pick-to: 6.4 6.3 Change-Id: I3ef27ed62c5dc25eed05d551c72743a1b8528318 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove uses of Q_ATOMIC_INT{8,16,32}_IS_SUPPORTEDMarc Mutz2022-07-062-32/+14
| | | | | | | | | | | It's always true these days, assert so in qatomic.cpp and tst_QAtomicInteger. Update the docs. Pick-to: 6.4 Change-Id: I3684cff96c1d2e05677314e29514cc279bd6b1a1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* unblacklist passing tests 2022Anna Wojciechowska2022-06-231-4/+0
| | | | | Change-Id: Ifb09a997d39fc2c92503e77cf372d443c13c4c2b Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
* QPromise: run continuation(s) on destructionSona Kurazyan2022-06-221-0/+20
| | | | | | | | | | | | | | | | | | If the QFuture is canceled because the associated QPromise has been destroyed, we still need to run its continuations (i.e. onCanceled handler, if it's attached), so replaced the cleanContinuation() call inside ~QPromise() with runContinuation(), which will also take care of cleaning the continuation. [ChangeLog][QtCore][Important Behavior Changes] QFuture now runs its continuations when its associated QPromise has been destroyed. Previously, if a QFuture was canceled because the associated QPromise has been destroyed, its continuations were skipped. Fixes: QTBUG-103992 Pick-to: 6.4 6.3 6.2 Change-Id: Ie05bc760c96c349aade8adb8d2fe5263aff8efac Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* tst_qthread: Fix compilation under ubsanFabian Kosmale2022-06-201-4/+4
| | | | | | | | | We missed the terminating ";" in the QSKIP lines. Amends ea4d6b987ae10f1bb910081b523c3b22b11f7b64 Pick-to: 6.3 6.4 Change-Id: Ibda43b8a84230c243dbcc74e157f4c3f8ef3891d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Skip tests that terminate threads under ASANVolker Hilsheimer2022-06-191-0/+16
| | | | | | | | | | | | | | | Thread termination might prevent stack unwinding, which then generates ASAN errors such as ERROR: AddressSanitizer: stack-buffer-underflow on address 0x7f3c1d7858b0 at pc 0x7f3c243d8918 bp 0x7f3c1d7857f0 sp 0x7f3c1d7857e8 Skip such tests so that we can enable blocking CI runs under ASAN. Fixes: QTBUG-104421 Pick-to: 6.4 6.3 Change-Id: I169235a12190e3f72525cddfe1a44a4bee19eca1 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Windows: fix DeferredDelete events processing on QThread::terminate()Vladimir Belyavsky2022-06-101-0/+78
| | | | | | | | | | | | On finishing/terminating a thread, when processing posted events, we need to consider QThread's own data instead of caller thread's data. Otherwise we can get into unexpected situations such as double destruction of an object, premature destruction, etc. Fixes: QTBUG-103922 Pick-to: 6.4 6.3 6.3.1 6.2 5.15 Change-Id: Idf77221ebbaa0b150ee2d0c296b51829ae8dc30e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove manual declarations of qGlobalPostedEventsCount()Marc Mutz2022-05-181-4/+0
| | | | | | | | | ... in favor of including qabstracteventdispatcher_p.h, where needed. Keeps the code DRY. Change-Id: I5bee2e653cb29ffac2601ff03c952a4b3adbdb9c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Guard the use of QWinEventNotifier in testsAlexey Edelev2022-05-171-0/+2
| | | | | | | | | Add the Q_OS_WIN32 guard for the include of QWinEventNotifier. Change-Id: I7824b2ee236a370c83fd85a2f594a39cf36b36e6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Use SPDX license identifiersLucie Gérard2022-05-1623-647/+50
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add support for unwrapping QFuture<QFuture<T>>Sona Kurazyan2022-04-211-0/+267
| | | | | | | | | | | | | | | | Added QFuture::unwrap() for unwrapping the future nested inside QFuture<QFuture<T>>. QTBUG-86725 suggests doing the unwrapping automatically inside .then(), but this will change the return type of .then() that used to return QFuture<QFuture<T>> and might cause SC breaks. Apart from that, QFuture::unwrap() might be helpful in general, for asynchronous computations that return a nested QFuture. [ChangeLog][QtCore][QFuture] Added QFuture::unwrap() for unwrapping the future nested inside QFuture<QFuture<T>>. Task-number: QTBUG-86725 Change-Id: I8886743aca261dca46f62d9dfcaead4a141d3dc4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Replace uses of _qs with _s in testsSona Kurazyan2022-04-071-2/+4
| | | | | | Task-number: QTBUG-101408 Change-Id: If092a68828a1e8056259cf90d035d9a87989244b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Android: activate tst_QThreadStorageIvan Solovev2022-03-253-9/+4
| | | | | | | | | | | Skip a test that uses QProcess instead of blacklisting it. Re-enable this test in CMakeLists.txt, so that it can be checked in the CI. Fixes: QTBUG-87431 Pick-to: 6.3 6.2 Change-Id: If8a4acd60735f355dffa60c28b8d07695ee33ec8 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* tst_QAtomicInt: do not check qlonglong alignment for x86_32 CPUsIvan Solovev2022-03-252-4/+2
| | | | | | | | | | | For x86_32 the alignment of QBasicAtomicInteger<8 bytes> is not equal to the alignment of TypeInStruct<8 bytes>, so do not perform the check. Fixes: QTBUG-87422 Pick-to: 6.3 6.2 Change-Id: I6e6c6cb7b2b7195e430d6a6991004bcfce16d4cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Always cancel unfinished QPromises on destructionSona Kurazyan2022-03-251-0/+14
| | | | | | | | | | | | | | | | | | If the QPromise is being destroyed, we should signal the associated futures to stop waiting. No matter in which state the promise is, if it's not finished, we should always cancel to avoid infinite waits. This is also what docs state: "The promise implicitly transitions to a canceled state on destruction unless finish() is called beforehand by the user." Fixes: QTBUG-101284 Pick-to: 6.3 6.2 Change-Id: I65ebfefe03b79b41afacda78a4f49938c54d8b37 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>