summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/thread
Commit message (Collapse)AuthorAgeFilesLines
* Long live QVERIFY_THROWS_EXCEPTION!Marc Mutz2021-11-261-1/+1
| | | | | | | | | | | | | Use variable args macros to swallow any extra commas in the expression. To use this, the type of the exception has to be first. Use Eddy's suggestion for a new name to avoid breaking the old macro. [ChangeLog][QtTest] Added QVERIFY_THROWS_EXCEPTION, replacing QVERIFY_EXCEPTION_THROWN, which has therefore been deprecated. Change-Id: I16825c35bae0631c5fad5a9a3ace4d6edc067f83 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtBase: replace windows.h with qt_windows.hYuhang Zhao2021-11-231-1/+1
| | | | | | | | | | We have some special handling in qt_windows.h, use it instead of the original windows.h Change-Id: I12fa45b09d3f2aad355573dce45861d7d28e1d77 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add support for combining multiple QFuturesSona Kurazyan2021-11-201-0/+514
| | | | | | | | | | | [ChangeLog][QtCore] Added QtFuture::whenAll() and QtFuture::whenAny() functions, returning a QFuture that becomes ready when all or any of the supplied futures complete. Task-number: QTBUG-86714 Change-Id: I2bb7dbb4cdc4f79a7a4fd494142df6a0f93a2b39 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QFuture: support cancellation of continuation chain through parentSona Kurazyan2021-11-131-0/+126
| | | | | | | | | | | | | | | | | | | This change allows canceling the chain of continuations attached to a future through canceling the future itself at any point of execution of the chain. [ChangeLog][QtCore][Important Behavior Changes] The chain of continuations attached to a future now can be cancelled through cancelling the future itself at any point of the execution of the chain, as it was documented. Previously canceling the future would cancel the chain only if it was done before the chain starts executing, otherwise the cancellation would be ignored. Now the part of the chain that wasn't started at the moment of cancellation will be canceled. Task-number: QTBUG-97582 Change-Id: I4c3b3c68e34d3a044243ac9a7a9ed3c38b7cb02e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Consistently restore threadpool limit at end of testsVolker Hilsheimer2021-10-221-12/+23
| | | | | | | | | | | Fix warning about unused variable, and use qScopeGuard to make sure that the limit of the global threadpool is restored even if one of the tests fail. Pick-to: 6.2 Change-Id: I36747cb451074cceea961561478210728ed6d313 Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize QPromise destructorSona Kurazyan2021-10-082-0/+72
| | | | | | | | | Unify cancel and finish in QPromise destructor in a single call. This saves us one extra mutex lock and atomic state change. Task-number: QTBUG-84977 Change-Id: Iac06302c39a2863008b27325fcf6792d4f58c8ae Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add a safer way to use QThreadPool::reserveThreadAllan Sandfeld Jensen2021-10-061-2/+52
| | | | | | | | | Add startOnReservedThread that specifically releases a reserved thread and uses it atomically for a given task. This can make a positive number of reserved threads work. Change-Id: I4bd1dced24bb46fcb365f12cbc9c7905dc66cdf1 Reviewed-by: David Faure <david.faure@kdab.com>
* Cleanup of qthreadpoolAllan Sandfeld Jensen2021-10-011-7/+56
| | | | | | | | | | | | | Don't bother overwaiting in waitForDone(), if it was done at one point after it was called we can return true. And do not stop threads recently awakened by a startThread call as they have tasks to do. Make allowing at least one thread regardless of reservation more standard instead of hacked in certain places. Pick-to: 6.2 Change-Id: I304bcdc5822f440d5e72fc33ba2aa1678c9ba0d0 Reviewed-by: David Faure <david.faure@kdab.com>
* tst_qthread: Don't use QVERIFY in multiple threads in threadIdReuse()Ievgenii Meshcheriakov2021-10-011-2/+5
| | | | | | | | | | Testlib is not thread safe. Store the status into variable and check it in the main thread instead. Pick-to: 6.2 Change-Id: I840c8a3dceb1115a1b81ffeaa0fab96f9d2f1ff0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QThread: Reset the system thread ID when thread exits on UnixIevgenii Meshcheriakov2021-09-291-0/+53
| | | | | | | | | | | | | | | | | | | | | Unix QThread implementation stores pthread_t as a system thread ID when the thread is created, but never resets the system ID when those threads are destroyed. Some implementations may reuse the same thread IDs for new threads, and this may cause QThread::wait() to erroneously complain that "Thread tried to wait on itself". This patch sets the system thread ID to nullptr when the thread is about to exit and be destroyed by the system. A regression test is added to tst_qthread. Fixes: QTBUG-96846 Pick-to: 5.15 6.2 Change-Id: I0850425dd0e09af50e59c9038e7e662a2a624beb Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Compile autotests for IntegrityTatiana Borisova2021-09-202-3/+9
| | | | | | | | | - process environment/DNS are OFF for INTEGRITY Task-number: QTBUG-96176 Pick-to: 6.2 Change-Id: I189a97f88c96a428586c31a66b8d250e04482900 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add missing dependencies of tests on their helper programsEdward Welbourne2021-09-172-11/+6
| | | | | | | | | | | | | | | | | This ensures that a command such as $ ninja tst_qlocale && ninja tst_qlocale_check will automagically build the syslocaleapp program that the test runs from a subtest. Similar for testlib's selftests and tst_QProcess. As a drive-by, pruned some legacy comments from when CMakeLists.txt files were generated from .pro files. Change-Id: I67691a8175aaef124d4104cf1898193993408bdf Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QThreadPool: Fix restarting of expired threadsIevgenii Meshcheriakov2021-09-151-0/+25
| | | | | | | | | | | | | | | | Ensure that expired threads have actually finished before attempting to restart them. Calling start() on a thread that is not yet finished does nothing. Add a regression test into tst_qthreadpool that attempts to trigger reuse of expired threads and verifies that all submitted tasks execute. Fixes: QTBUG-72872 Pick-to: 6.2 Change-Id: I2109b628b8a4e91491115dc56aebf3eb249646b5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Skip tst_QReadWriteLock::multipleReadersLoop on QEMUSona Kurazyan2021-09-092-0/+5
| | | | | | | | | | The test is randomly failing in the CI on QEMU. Couldn't reproduce it on the actual armv7 hardware, so most likely it's not a Qt bug. Fixes: QTBUG-96103 Pick-to: 6.1 6.2 Change-Id: I60b7264c6ce44b3b327fdd0dbcede006717c65a6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use constexpr for constants and ranged-based for loopsEdward Welbourne2021-08-231-99/+89
| | | | | | | | | In the process, actually use the constants as the size of some arrays, instead of making [1024] arrays and then only using a few entries. Change-Id: I9f36b322840393b8680788190cf8b40a828f4957 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QtConcurrent::run: support non default-constructible return typesSona Kurazyan2021-08-181-4/+4
| | | | | | | | | | | | | | The QtConcurrent::RunFunctionTask class keeps a variable to store the result of QtConcurrent::run when it becomes available, so that it can be reported afterwards. This requires the result type to be default-constructible. However there's no need in storing the result, it can be reported immediately after it becomes available. Pick-to: 6.1 6.2 Fixes: QTBUG-95214 Change-Id: I95f3dbff0ab41eaa81b104a8834b37d10a0d193a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Attempt to unwedge tst_QThread::wait3_slowDestructor()Edward Welbourne2021-08-171-13/+15
| | | | | | | | | | | | | | | | When the test failed, it never released the blocking slot, so the tested thread remained blocked indefinitely. Blacklisting doesn't rescue that: the test run gets killed by Coin's watchdog. Use a QScopeGuard() to release the clocked slot on failure. replacing the release that was happening only on success. As drive-by clean-up, smarten up the code a little and remove an unused enum. Pick-to: 6.2 6.1 5.15 Change-Id: Ie035dafe6e4b1d82aea5de38ceb31c0f7fcf81d7 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* tests: fix some -WvolatileMarc Mutz2021-07-284-16/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | C++20 deprecated compound volatile statements such as pre- and post-increments, to stress that they're not atomic. So instead of volatile i; ~~~~; ++i; you're now supposed to write volatile i; ~~~~; int j = i; // volatile load ++j; i = j; // volatile store which matches more closely what hardware does. Instead of fixing every use of volatile pre- or post-increment in this fashion individually, and realising that probably a few more Qt modules will have the same kind of code patterns in them, write QtPrivate functions to do the job centrally. Change-Id: I838097bd484ef2118c071726963f103c080d2ba5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Don't report results when the results list is emptySona Kurazyan2021-07-272-0/+36
| | | | | | | | | | | | | | | | | | When inserting items into the result store, a ResultItem is created, which stores a pointer to the results list and their size. If the size of the ResultItem is set to 0, it means that a single result is stored. In case of trying to report results via an empty list, the size is 0, so result store treats it as a single result. Added checks before storing the results to make sure that the result list isn't empty. Note that empty lists are allowed in some cases for the filter mode, because ResultStoreBase::addResults() knows how to handle those cases correctly. Task-number: QTBUG-80957 Pick-to: 5.15 6.1 6.2 Change-Id: I399af4c3eef6adf82fea5df031fe9a9075006b1f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Make QFutureWatcher::isFinished() consistent with the watched QFutureSona Kurazyan2021-07-231-25/+50
| | | | | | | | | | | | | | | | | | | | | All the getters of QFutureWatcher are consistent with the getters of the corresponding QFuture, except for the isFinished() method, which returns 'true' only after the finished() signal is delivered. This behavior might be unintuitive for the users. In particular, isFinished() returns 'false', even if it's called immediately after waitForFinished(). [ChangeLog][QtCore][QFutureWatcher][Important Behavior Changes] The QFutureWatcher::isFinished() method now indicates if the related QFuture is finished, instead of indicating if the finished() signal was delivered. This makes it consistent with the future that is being watched. Fixes: QTBUG-91048 Pick-to: 6.1 6.2 Change-Id: I6ae9b882b23e06198a82c95b026491bd480b3bf0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Skip tst_qthreadonce test on QEMUSona Kurazyan2021-07-202-0/+11
| | | | | | | | | | | | The test causes frequent failures in the CI. Couldn't reproduce on actual arm64 hardware, so it's likely to be a QEMU bug. From the available logs it seems that all the test cases are flaky (there's a failure even after cleanupTestCase() is called), so disable all of them. Fixes: QTBUG-94737 Pick-to: 6.1 6.2 Change-Id: I783ec2179ba779a2c8d93351a78e8472a4f7a907 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QMetaType: Support converting any QFuture<T> to QFuture<void>Arno Rehn2021-07-151-0/+18
| | | | | | | | | | | | | | | | QMetaType now implicitly knows how to convert any QFuture<T> to QFuture<void> without needing to manually register a converter function. QtWebChannel will make use of this to transparently support QFuture<T> return types. [ChangeLog][QtCore][QMetaType] QMetaType now supports converting any QFuture<T> to QFuture<void>. Task-number: QTBUG-92903 Change-Id: Ied7e71be37c346cc3d2c274ffb0d91a6821ab4d4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add QFutureInterfaceBase::get() to retrieve internals of QFutureArno Rehn2021-07-121-0/+11
| | | | | | | | | | | | For generic interop with other parts of Qt, we need to be able to extract the type-erased internal storage of QFuture<T>. In particular, QtWebChannel needs this to transparently support QFuture<T> as a method return type. Task-number: QTBUG-92903 Change-Id: I763f054656b8810d58720262d364baf42c47eb37 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QSemaphore: add <chrono> overload of tryAcquire()Marc Mutz2021-06-301-1/+35
| | | | | | | | | | | | | | | ... and C++20 std::counting_semaphore API compatibility. [ChangeLog][QtCore][QSemaphore] tryAcquire() now optionally takes a <chrono> duration as timeout, not just int milliseconds. [ChangeLog][QtCore][QSemaphore] Added try_acquire{,_for,_until}() for C++20 std::counting_semaphore compatibility. Change-Id: I34b6b4bf57a54745d4b97349903d090c4995338a Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QTestlib: Add formatting for QObject * in QCOMPAREFriedemann Kleint2021-05-261-2/+3
| | | | | | | | | | | Output object name and class in QCOMPARE(). This should help to debug flaky QWidget tests that for example check on focusWidget(). [ChangeLog][QtTestLib] QCOMPARE() now reports QObject * values by class and objectName(). Task-number: QTBUG-64446 Change-Id: Ife04e89bba04fc78d077c8f0f07af17a17c9cf8c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QFuture/QPromise: don't check for is_copy_constructibleGiuseppe D'Angelo2021-05-211-1/+0
| | | | | | | | | | | | | The check is over-arching. is_move_constructible is sufficient; we don't have to support "ridiculous" types that are copiable but have deleted move operations (such types are fundamentally broken). This is in line with the Move* (legacy) named requirements. Change-Id: Idc7116b39013501b9be39628a4e7afd35fe15530 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* Add new app permissions API under QCoreApplicationAssam Boudjelthia2021-05-051-2/+2
| | | | | | | | | | | | | | | | | | | | | The API allows users to request and check the status of various permissions. A predefined enum class of the common permission types on different platforms is used to allow requesting permission with a common code. Platform specific permissions are defined only on their relevant platform. For permissions that are not predefined, they can be requested via a string variant of this API. This adds the Android implementation only. [ChangeLog][QtCore] Add new API for handling app permissions with an initial implementation for Android. Task-number: QTBUG-90498 Change-Id: I3bc98c6ab2dceeea3ee8edec20a332ed8f56ad4f Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QThreadPool: obey the docs that say we always use at least 1 threadThiago Macieira2021-04-241-1/+1
| | | | | | | | | | | | | | Even if the user (usually accidentally) sets a thread count of zero or negative. The reporter in the bug report did QThread::idealThreadCount() - 1 on a 1 CPU system... Drive-by add to the documentation and the missing #include. Pick-to: 6.1 6.0 Fixes: QTBUG-93007 Change-Id: I6cdea00671e8479b9c50fffd167807d14e030154 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* tst_qpromise: build fixGiuseppe D'Angelo2021-04-201-4/+4
| | | | | | | | | | | | | | The test use aggregate initialization on some classes which however are no longer aggregates in C++20 (the rules changed again; in C++20 having a user-*declared* constructor makes a class not an aggregate). Just add a constructor so the code keeps compiling in both 17 and 20. Fixes: QTBUG-92963 Pick-to: 6.0 6.1 Change-Id: I52371c5ee34c84358987b5ae8bee9ab9c49c8eab Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QtFuture::connect: disconnect signals firstMårten Nordheim2021-04-121-0/+19
| | | | | | | | | | During reportFinished we may call a continuation which might end up triggering one of the signals. Pick-to: 6.0 6.1 Change-Id: I19546fcca12be71cd536e4287eb5eddd9d236830 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add support to set thread priority to QThreadPoolSamuel Gaist2021-04-031-0/+20
| | | | | | | | | | | | | | | | | | Currently, QThreadPool's generated threads inherit the priority from the thread they are created and that cannot be changed. This merge request adds a property to QThreadPool so that the priority of the threads can be different. The default behavior does not change. [ChangeLog][QtCore][QThreadPool] QThreadPool can now be configured to use a different thread priority when creating new threads than the one it inherits from the thread it was created in. This will only apply to the threads started after the property is changed. Fixes: QTBUG-3481 Change-Id: Ic98d4312d055a3357771abb656516ebd0715918d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix warning about virtual overrideAndreas Buhr2021-03-051-1/+1
| | | | | | Change-Id: Ia9928c8ef5d1597e55f45c67c462c1e9756ee899 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* tst_QFuture::continuationsWithContext: fix the flakinessSona Kurazyan2021-02-251-3/+14
| | | | | | | | | | | | | | | | | When attaching a continuation with the default (QtFuture::Launch::Sync) policy, it will be launched in the same thread where the parent has been executing, or in the thread where the parent lives, if the continuation is attached after the parent has already finished. Fixed the test-case to make sure the continuations are attached while the parent is still running, so that they can be resolved in the parent's context. Fixes: QTBUG-91373 Pick-to: 6.1 Change-Id: I82b3b0c47b76d121b44bd512659c08b3b474e351 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Move QEMU emulation detector to QTestSamuli Piippo2021-02-132-5/+4
| | | | | | | | | The emulation detection has been usable only on qtbase tests, move it to QTest so that it can be used in other modules as well. Pick-to: 6.1 Change-Id: I4b2321b7856414d7b1cfd5e6b1405a633c6bb878 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Revert "Port QThreadPool to the new property system"Allan Sandfeld Jensen2021-01-291-78/+14
| | | | | | | | | | This reverts commit 8f8405e04642b98663d4752d4ae76c304ae33b01. Reason for revert: Appears not entirely thread-safe and caused QTBUG-90705 Change-Id: I390c0b1a555a18e6a095b52010371d017071e26b Fixes: QTBUG-90705 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Port QThreadPool to the new property systemSona Kurazyan2021-01-271-14/+78
| | | | | | | | | | | Ported all properties, except activeThreadCount. Marking it dirty may cause a re-evaluation of properties depending on it, which may reault in a deadlock in case of trying to read activeThreadCount property which is being marked as dirty. Task-number: QTBUG-85520 Change-Id: Id073b0895c89a9e6b05b57ad520db994e550a1c9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* tst_QThreadPool: avoid a potential memory leaksSona Kurazyan2021-01-191-53/+45
| | | | | | | | | Don't use raw pointers when allocating memory, it won't be deleted if the test-cases fail. Change-Id: I212a12c988f401f97c2c92a7fae09b2aa7d913a9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
* Remove .prev_CMakeLists.txt filesJoerg Bornemann2021-01-123-56/+0
| | | | | | | | | | Those serve no purpose anymore, now that the .pro files are gone. Task-number: QTBUG-88742 Change-Id: I39943327b8c9871785b58e9973e4e7602371793e Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Remove the qmake project filesJoerg Bornemann2021-01-0739-202/+0
| | | | | | | | | | | | | | | | Remove the qmake project files for most of Qt. Leave the qmake project files for examples, because we still test those in the CI to ensure qmake does not regress. Also leave the qmake project files for utils and other minor parts that lack CMake project files. Task-number: QTBUG-88742 Change-Id: I6cdf059e6204816f617f9624f3ea9822703f73cc Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-2220-21/+38
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Clean-up warnings in corelib/thread testsSona Kurazyan2020-12-1716-122/+122
| | | | | | | | | | | | | | Fixed the following warnings: - empty expression statement has no effect; remove unnecessary ';' to silence this warning - zero as null pointer constant - no previous extern declaration for non-static variable - use of old-style cast - integer conversion warnings Change-Id: Ieb31b127ce8e3b543aaf88a8e8fc463dcc8bc4e3 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Add support of invoking QFuture continuations in a given contextSona Kurazyan2020-12-111-0/+80
| | | | | | | | | | | | Added overloads of .then()/.onFailed()/.onCanceled() which take a pointer of a context object, and invoke the continuations in the object's thread. Task-number: QTBUG-86794 Change-Id: I0f3cbb0500695673fc4087af5d4b96b416e3e1ce Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Add convenience functions for QFuture creationIvan Solovev2020-11-231-0/+69
| | | | | | | | | | [ChangeLog][QtCore][QFuture] Add convenience functions to create a ready QFuture and a QFuture with an exception Task-number: QTBUG-86713 Change-Id: Ic7f9ca590a8ea8a9696b84f35bad074780794461 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Get rid of Q_COMPILER_CONSTEXPR checksAllan Sandfeld Jensen2020-11-172-14/+0
| | | | | | | Is required now. Change-Id: I62e95929d1649ea1390392230b619bd56d2a0349 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Track progress range in QFutureInterface::setProgressValueIvan Solovev2020-11-172-1/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously QFutureInterface::setProgressValue was silently ignoring the progress range and allowed to set any progress value. Also no checks were performed in QFutureInterface::setProgressRange, which allowed the user to set minimum > maximum. Add checking of the current progress range, when settings the progress value. Add checks for minimum and maximum values while setting the progress range. The implementation of the checks is mostly based on the logic that is used in QProgressBar. - If maximum is smaller than minimum, minimum becomes the only legal value. - If the current progress value falls outside the new range, the progress value is set to be minimum. - If both progressMinimum() and progressMaximum() return 0, the current progress range is considered to be unused, and any progress value can be set. - When setting the value using setProgressValue(), if the value falls out of the progress range, the method has no effect. Task-number: QTBUG-84729 Change-Id: I29cf4f94b8e98e1af30dd46fbdba39c421cf66bf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Conditionally disable code snippets that depend on cxx11_futureSona Kurazyan2020-11-131-0/+6
| | | | | | Fixes: QTBUG-88392 Change-Id: Ida215253fdcad66a5a67084d3ff6781583101859 Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
* Conditionally disable tests that depend on cxx11_future flagSona Kurazyan2020-11-122-0/+50
| | | | | | | Fixes: QTBUG-88392 Change-Id: I33b8ffd72be8a653e0923ef1e57305ffaf6b0428 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use built-in C++ foreach iteration in testsDavid Skoland2020-11-061-2/+2
| | | | | Change-Id: I1e4bf9249ce26c034c676d78cfa16231226da05b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Android: blacklist a list of failing tests for androidAssam Boudjelthia2020-11-045-4/+26
| | | | | | | | | | | | | | | | We want to re-enable Android tests in QTQAINFRA-3867. However, many tests are failing already preventing that from happening. QTBUG-87025 is currently keeping track (links) to all of those failing tests. The current proposal is to hide those failing tests, and enable Android test running in COIN for other tests. After, that try to fix them one by one, and at the same time we can make sure no more failing tests go unnoticed. Task-number: QTBUG-87025 Change-Id: Ic1fe9fdd167cbcfd99efce9a09c69c344a36bbe4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Forbid implicit conversions between QFuture and other typesSona Kurazyan2020-10-302-21/+15
| | | | | | | | | | | | | | | | | | | | | - Remove the casting operator of QFuture<T> to T. It calls QFuture::result(), which may lead to undefined behavior if the user has moved the results from QFuture via QFuture::takeResult() before trying to do the conversion. - Disable implicit conversion of QFuture<T> to QFuture<void>, by making the constructor explicit. If the users really intend to do the conversion, they should do it explicitly. [ChangeLog][Source-Incompatible Changes][QFuture] Implicit conversions of QFuture<T> to T and to QFuture<void> have been disabled. Use QFuture::result() or QFuture::takeResult() where you need to convert QFuture<T> to T. Use the explicit QFuture<void>(const QFuture<T> &) constructor to convert QFuture<T> to QFuture<void>. Change-Id: I153d4137d36365b1611ac934fb3ac2eb667fdd6c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>