Introduce a helper function to silence this lengthy warning, and use
it consistently in all places where the warning was triggered.
Amends 502a7706b9 which introduced the
warning.
Pick-to: 6.5
Change-Id: Ifa5c7e0182a12885af4db42ef5d68b1f27a0c6bc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit a30289ee0be41e8311aef6d8737885b354a9f047)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 08ef73f94f6428f8cefc0386980b2ba1f63bee84)
Both whenAll() and whenAny() have two overloads:
* an overload taking two input iterators, e.g.
whenAll(IntpuIt begin, InputIt end)
* an overload taking an arbitrary number of future objects, e.g.
whenAll(Futures &&... futures)
The public APIs are properly constrained, but internally they call
QtPrivate::when*Impl() template functions, that have the same two
overloads, but do not have any constraints.
As a result, passing exactly two QFuture<T>{} objects was leading to
the compiler picking the Impl overload that takes a pair of iterators.
Fix it by applying a subset of constraints from the public API to
the private implementation as well.
Amends 102f7d31c4 which was introduced
for Qt 6.3, so picking down to Qt 6.5.
Fixes: QTBUG-131959
Pick-to: 6.5
Change-Id: Ide29ac9a494d07870e92957c40c1f614e56825f8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 8aef5b0d8fd57684abe39c88af8c14d8882ef07b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 90fab1e4e98962ecaff5fd66d218d4f76cb7b8cd)
When we consolidated "all" test functions to use RUN_TEST_FUNC, the
cancel() test function was inexplicably overlooked.
This patch ports this last test function.
Amends 4c00337ccb8e4266fa5a4af4fba40e5b62aba81b, whose commit message
contains rationale for this change, but not repeated here.
Pick-to: 6.5 6.2
Change-Id: I9461f8e816a25c731d6229df15ee88dcc8c4e165
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 3e71f256d5813ef699a4030f718fee1d1e53bba1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The implementation checks the state and returns without storing the
exception when its canceled or finished.
Add tests for both situations.
Done-with: Ivan Solovev <ivan.solovev@qt.io> (analysis and phrasing)
Pick-to: 6.5 6.2
Fixes: QTBUG-128405
Change-Id: I4610a022ea12e1bc9ce24cb17b972b5b9e051f0a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 6efec3850da188d3bba075185aa6e5c264c815eb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Don't just silently succeed.
As a drive-by, keep the skipped code visible to the compiler.
QThread::create() is universally available since
4a5f3c8b93, so the skipped code ought to
compile.
Amends ac6a9f9bfa.
Change-Id: I193ecf802ffbfd103747aa34eb307fb1a814a94e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4e1b20893aeeb9580bc6b52ac4baea297675bfee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Commit 1ed0dd88a3 moved the finish()
functionality from immediately after run() returns to the time of
thread-local destruction, to make sure that user destructors didn't run
after our cleaning up. But as a side effect, it made other user code run
too late, after some thread-local statics had been destroyed.
This is a common practice, which causes the destructor for worker to run
too late:
worker->moveToThread(thread);
...
QObject::connect(thread, &QThread::finished, thread, &QObject::deleteLater);
QObject::connect(thread, &QThread::finished, worker, &QObject::deleteLater);
This commit splits the cleanup in two phases: QThreadPrivate::finish(),
which runs immediately after run() and will call back out to user code
(finished() signal and delivery of deleteLater()), and cleanup() that
cleans up the QThread{Private,Data} state and destroys the event
dispatcher. That destruction is the only call out to user code.
I've removed the complex mix of pre-C++11 pthread_setspecific() content
and C++11 thread_local variables in favor of using one or the other, not
both. We prefer the thread-local for future-proofing and simplicity, on
platforms where we can verify this C++11 feature works, and because it
allows us to clean up QThreadData and the event dispatcher as late as
possible. (There's some code that runs even later, such as pthread TLS
destructors, used by Glib's GMainLoop)
Unfortunately, we can't use it everywhere. The commit above had already
noticed QNX has a problem and recent bug reports have shown other
platforms (Solaris, MUSL libc) that, 13 years after the ratification of
the standard, still have broken support, so we use pthread for them and
we call cleanup() from within finish() (that is, no late cleaning-up,
retaining the status quo from Qt 4 and 5). See QTBUG-129846 for an
analysis.
Drive-by moving the resetting of thread priority to after finished() is
emitted.
[ChangeLog][QtCore][QThread] Restored the Qt 6.7 timing of when the
finished() signal is emitted relative to the destruction of thread_local
variables. Qt 6.8.0 contained a change that moved this signal to a later
time on most Unix systems, which has caused problems with the order in
which those variables were accessed. The destruction of the event
dispatcher is kept at this late stage, wherever possible.
Fixes: QTBUG-129927
Fixes: QTBUG-129846
Fixes: QTBUG-130341
Task-number: QTBUG-117996
Change-Id: Ie5e40dd18faa05d8f777fffdf7dc30fc4fe0c7e9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4fabde349f16b59f37568da2a4c050c6dd53a34e)
The commit 1f22fc995a introduced nested
functions without properly checking their return status with
QTest::currentTestFailed().
Later, commit 855c448469 used the same
pattern.
Fix all the affected tests by wrapping the function calls into the
pre-existing RUN_TEST_FUNC macro.
Both commits were picked to 6.5, so do the same with this patch.
Pick-to: 6.5
Change-Id: I3e11bf5724d9b89c75a4e5c73c96f9566c36b5cd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 4c00337ccb8e4266fa5a4af4fba40e5b62aba81b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
For some reason, 4d6cf54664a98e01d4caab42431c62d6deb9f86e didn't treat
all lambdas, and no-one noticed.
This patch completes the task by transforming the remaining lambdas to
be non-move-only.
Amends 4d6cf54664a98e01d4caab42431c62d6deb9f86e, whose commit message
is pertinent to this patch, too, but not repeated here.
Pick-to: 6.5 6.2
Change-Id: I6dfe6eb438065e16fcb7ab1f2efcb64c0146bb6c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 5c3dc2ecb97b69eb12e06c499ddb50666be60be6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
VxWorks, at least as used in the 6.8 CI, has a problem with move-only
lambdas passed to QThread::create(). This might have been the reason
for the resurrection of the cxx11_future feature in
408430a543ef605157963b1a894847c7ba9f9956.
This patch tries to work around the issue by not moving the promise
into the lambda capture, but caputuring it by reference, and then
moving it into a local stack variable. In all cases, the ThreadWrapper
is created after the promise, so, since the ThreadWrapper dtor join()s
(like jthread), the promise out-lives the thread, and the destruction
of the promise happens-after the join() with the thread. So, no data
races. Code mustn't touch the promise object from the main thread once
the ThreadWrapper has started, but that's the case already and the
test functions are small enough for any such future use to be obvious
in review.
Amends 385f0732d9 and
4e1b20893aeeb9580bc6b52ac4baea297675bfee.
It appears that dev no longer has the problem¹, but apply this to dev,
too, to maintain consistency with the test in last three LTS releases.
¹ 4e1b20893aeeb9580bc6b52ac4baea297675bfee passed, but its cherry-pick
to 6.8 did not
Pick-to: 6.5 6.2
Change-Id: If1feba9d3a7f8677789d45fa9f4990cf44145709
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 4d6cf54664a98e01d4caab42431c62d6deb9f86e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
They are an unnecessary hit on build time.
Rewrite the tests using the standard Qt conventions.
Change-Id: Iac47e62c58b1805c3b4a0ac4f4b3db206c66cc65
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 6ddf74716d7b2fe0df5dd9c0172f9ecf936d5c5d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
There's nothing in our documentation saying this is permitted, but we
have specific code for it on Windows and it works on Unix because we
just wait on a QWaitCondition.
Change-Id: Id6331fa9aad473cb4f35fffdf8bb04d9a34cd108
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 5b5297fe87859f59a7aaf5e86a8915c00714fefa)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Lambdas that only capture by reference never need to be mutable.
Drop the keyword (and the now-superfluous parentheses).
Amends 385f0732d9.
Pick-to: 6.5 6.2
Change-Id: Iaa6451c1c26f1aed198c447ee59198c4e0285b15
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 37daf732d5089c58a6428124263243509d152987)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Not all test cases inspect all of failed, then, and canceled, but it
doesn't hurt to always collect all three.
Avoids having to write the same type of code over and over again.
Amends bf3fc5c95c (but really
1f22fc995a and
855c448469, which each duplicated the
initial pattern without refactoring).
Pick-to: 6.5 6.2
Change-Id: Ifb2a3589f8aed9017fbdff20e4edb64e8c9e2488
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 9d0da873f0ddadb60e61fbd6c96c8b00f026e99f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
In unit-tests, blocking operations should be timed, whenever possible,
so that a proper failure is logged instead of a watchdog timeout
(which is reported as a crash).
Wait for 60s and wrap the wait() in QVERIFY(). Since this can fail,
mark ThreadWrapper's dtor as non-noexcept.
Amends 385f0732d9.
Pick-to: 6.5 6.2
Change-Id: I3462017cb1a7580c901b98e9b1c3741853f32dc6
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 32d12c2ebace41361c789e5aa58430ebf9f687b1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
It's supposed to indicate a thread never expires, but following
a change where it stores the expiry with chrono we no longer considered
a negative expiry as 'forever', but rather it immediately expires!
More directly it is because we end up calling
QDeadlineTimer::setPreciseRemainingTime(0 secs, X nsecs), and it only
cares about negative seconds to set Forever. There are complications to
consider nsecs for this since several nanoseconds may pass between
initially calling the function and assigning the values...
Amends 1f2a230b89.
Fixes: QTBUG-129898
Change-Id: I9626de31810fb2751ff6d83165d7dce5258a9baf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit c57027199996d0f0d2ac8ebc4505c78afa54ab5a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The QThreadPrivate::finish() cleanup code is not prepared to be
subjected to POSIX cancellation: if, like on glibc, thread
cancellation is implemented by stack ununwinding, we get exceptions in
dtors and therefore std::terminate(), and otherwise, we leak
resources.
It would be very hard to make the code robust against this, as it
would require all cleanup to be wrapped in pthread_cleanup_push/pop,
with the added problem that these functions need to appear in the same
lexical scope. Another alternative would be to move all cleanup code
into a thread_local destructor, but it's not clear whether code
running as part of thread_local destruction would be exempt from
cancellation, and it would be a major rewrite.
The simplest method is to disable cancellation for the remainder of
the thread lifetime in the shutdown code, just like the startup code
only enables cancellation after initial setup, so do that.
[ChangeLog][Important Behavior Changes][QThread] On Unix,
fixed a race of QThread::terminate() with normal thread exit (running
off the end of run()) which could corrupt QThread's internal cleanup
code. The fix involves disabling thread cancellation for the remainder
of the thread's lifetime once control reaches QThread's cleanup
code. If you rely on a PTHREAD_CANCELED return status, be aware that
this change may mask late cancellations. Likewise, slots connected to
QThread::finished() using Qt::DirectConnection are now run in a regime
where thread cancellation is already disabled. If you need
cancellation in that situation to work, you need to define your own
finished()-like signal and emit that at the end of run().
Fixes: QTBUG-127008
Change-Id: I23030eefdfcebf0a6d6796db5cbbbf0812ae12c0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 01d4be4a8327458a3242804594b498f840480289)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Doesn't test anything, just that it doesn't crash.
Turns out we have a race between thread cancellation and normal exit
(filed as QTBUG-127008). Worked around by adding an infinite loop to
run(), after terminate().
Android doesn't support cancellation at all, and our Windows
implementation hits QTBUG-127050, so skip the test on those
platforms.
Pick-to: 6.7 6.5 6.2 5.15
Change-Id: I47a635a31caaf116d3688f31b9b5c5875e9765f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit a9f7e75a2647732ff998f1c0d112682dbd5c4e28)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The VxWorks implementation of std::variant is broken.
std::visit throws std::bad_variant_access when called on a variant with
duplicated types.
Skip the tests that are affected by it.
Pick-to: 6.7
Task-number: QTBUG-115777
Change-Id: I45227cc543ef7db2217b1d53313c2e2b140988d6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 0e9c0c0847bd09c8a2b5166a2bafc103db0d3abc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
The test failure seems to be related to code optimizations and not
to the c++ standard that is used. With a recent version of MSVC
(>=19.40) the test fails on both x64 as well as ARM64 if the build
configuration does code optimizations (aka we have a release
build).
Pick-to: 6.7
Fixes: QTBUG-126349
Change-Id: I01781ea5b20f80a6cbd7ccb284d30b5d078ad958
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit d8cb2044e3e86633c732f1f1b28926062b08b76c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Replace class operators operator==(), operator!=() of
QtPrivate::ResultIteratorBase 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: Ib9a50a400df86d1dc034d2a0cfee804109a2b93f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Replace class operators operator==(), operator!=() of
QFuture::const_iterator: to friend method comparesEqual() and
Q_DECLARE_EQUALITY_COMPARABLE macro.
Task-number: QTBUG-120304
Change-Id: Ifa264b83f4d5623db99820847ab9a800cca99be2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
We need it to run after all the thread-local destructors have run, to
ensure that some user code hasn't run after QThreadPrivate::finish() has
finished. We achieve that by making it get called from a thread-local
destructor itself, in the form of a qScopeGuard.
This ought to have been done since C++11 thread_local with non-trivial
destructors became available. However, it only started showing up after
commit 4a93285b16 began using thread_local
inside Qt itself. The visible symptom was that QThreadPrivate::finish()
had already destroyed the thread's event dispatcher, but some user code
ran later and expected it to still exist (or, worse, recreated it, via
QEventLoop → QThreadData::ensureEventDispatcher).
Fixes: QTBUG-117996
Pick-to: 6.7
Change-Id: I8f3ce163ccc5408cac39fffd178d682e5bfa6955
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Now developer build tests compile, but some are not working.
Functional fix will come later via separate tasks.
Task-number: QTBUG-122999
Change-Id: I70487b46c1b32ba4279cb02a4978e4f55ac0d310
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This allows a more efficient way of checking whether a thread is the
currently executing one (without using private API).
Change-Id: I007edae6b258d7e42e901fa720d4f3cf9fe25a49
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Some of these would break if we changed the start(Priority) to say
start(QThread::Priority) instead.
Pick-to: 6.7 6.5 6.2
Task-number: QTBUG-124723
Change-Id: Id3ebe73718c8acbc54a2c88158f4062fd0dd5be1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
We are selecting a subset of the tests for batching/CI,
however this is done for the WASM configuration which
interferes with non-batched tests.
- we can only build and run tests which are in the
batching subset
- we are enabling threading tests which breaks the
no-thread configuration.
Add QT_BUILD_WASM_BATCHED_TESTS and enable for WASM and
batching. There's then no restrictions on which tests
can be selected for CI.
Change-Id: I59a67b63e80cd00676cb28f916951d2a52b0ee2c
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
It is passing on my machine with Visual Studio 17.10 Preview 1.
But only with C++20 enabled.
Pick-to: 6.7 6.6 6.5
Task-number: QTBUG-101761
Change-Id: Ia5af3d75d35dda1df9b39bdc94f07dd746ff60af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
When connecting a QFutureWatcher to the QFuture it will connect to the
output interface, which will queue up events to notify about the current
state. This happens in the thread of the QFutureWatcher.
Since 07d6d31a4c unfortunately the sending
of those events was done outside the lock, meaning the worker-thread
could _also_ send events at the same time, leading to a race on which
events would be sent first.
To fix this we move the emission of the events back into the lock
and because it is now inside the lock again anyway, we will revert
back to posting the callout events immediately, so this patch also
partially reverts 07d6d31a4c
Fixes: QTBUG-119169
Pick-to: 6.7 6.6
Change-Id: If29ab6712a82e7948c0ea4866340b6fac5aba5ef
Reviewed-by: Arno Rehn <a.rehn@menlosystems.com>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
I don't know what it is but it's not 1, because it is quite
often flaky in these tests. A single failure leads to deadlock
that takes 5 minutes to fail. Then a rerun might do another
5 minutes and fail the integration, or it will pass but take
longer to do so.
Pick-to: 6.7 6.6 6.5
Change-Id: I188276df7800b00a20dbe39edee91c582f0a82a7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Some machine in CI is failing some of these sometimes and
I would like to know by how much.
Pick-to: 6.7
Change-Id: I88b41d5cde81419f7c11f7038101962630eb31ef
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Changed type of `id`, `int` -> `size_t`, to match `liveCount`, in
`CountedObject` struct.
Fixes: QTBUG-122301
Change-Id: I85513d5ff6a4f0c3fb53f77e55c43b1284d1b1a8
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
According to QUIP-18 [1], all tests file should be
LicenseRef-Qt-Commercial OR GPL-3.0-only
[1]: https://contribute.qt-project.org/quips/18
Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
cxx11_future flag should be disabled for VxWorks. VxWorks still does
have some bugs related to this std features and some parts of code needs
to be excluded. At least till the 24.03 VxWorks release as for now this
is the expected release that should contain fixes.
Task-number: QTBUG-115777
Change-Id: Ic652403697d727f4ae05ae7287ff8285075d3802
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This patch replaces the QBasicFutureWatcher that was used for
continuations with context objects with a smaller QObject-based wrapper
that works directly from the actual continuation.
The idea stays the same: In order to run continuations in the thread of
a context object, we offload the continuation invocation to the
signal-slot mechanism.
Previously, we've hooked into QFuture with QFutureCallOutInterface to
emit a signal and trigger continuation invocation. However, it is much
easier and robust to emit that signal from the continuation itself.
This sidesteps the locking issues that QFutureCallOutInterface handling
presents. QFutureCallOutInterface basically requires any consumer to
only access the QFuture after all events have been posted and the
internal mutex unlocked, i.e. on the next cycle of the event loop.
Continuations do not impose this restriction; runContinuation()
explicitly unlocks the internal mutex before calling the continuation.
This fixes a deadlock when using QFuture::then(context, ...) where
the paren future is resolved from the same thread that the context
object lives in.
Fixes: QTBUG-119406
Fixes: QTBUG-119103
Fixes: QTBUG-117918
Fixes: QTBUG-119579
Fixes: QTBUG-119810
Pick-to: 6.7 6.6
Change-Id: I112b16024cde6b6ee0e4d8127392864b813df5bc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Remove the following CIs from BLACKLIST files as they are no longer
used:
- msvc-2015
- msvc-2017
- windows-7sp1
- opensuse-42.3
- ubuntu 16.04/18.04/20.04
- rhel 6.6/7.4/7.6
- redhatenterpriselinuxworkstation-6.6
Change-Id: Ief9550e3455a1ed211d978933262c8d5557b0fec
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Test runner was not properly handling tests which
return the control back to browser event loop.
It was treating such tests as if they exited with
code 0, marking them as succesfull even if they were
eventually failing or hanging.
This commit adds a callback to TestCase so the runner
is notified when a test truly has finished.
As a side effect, two tests need to be disabled for now
as they are failing for wasm, which was not properly
detected previously.
Change-Id: I0eb9383e5bb9cd660431c18747b9e94413629d1e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This reverts commit 6a93ec2435.
Reason for revert: Breaks qtdeclarative build, submodules need
to be clean before we deprecate or remove APIs.
Change-Id: Id0726b9bfad6072065b380b44b6ff6dffda79e45
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
These special member functions have no purpose.
We never *documented* their semantics. Any code using them is
unconditionally wrong (which semantics was it assuming?), so we can
accept the SIC (type A). If a user needs such a copy, they would have to
reason on the intended semantics (relaxed? acquire/release?) and be
explicit in their code. Especially for assignment, they would need
understand the consequences of the memory ordering that apply on _each_
atomic object involved and not on the assignment operation as a whole
(there are no such semantics).
Testing this change on qtbase has already found bugs.
From a purely technical point of view: we don't guarantee lock-free
atomics nor we require them from the underlying platform. An atomic is
therefore allowed to be implemented as a mutex protecting a value, and
mutexes are not copiable. std::atomic follows the exactly same pattern
(not copiable nor copy-assignable) for exactly the same reasons, and Qt
atomics are implemented on top of std:: ones.
[ChangeLog][QtCore] The copy constructor and assignment operators of
Qt atomic classes (QAtomicInteger, QAtomicPointer) have been removed.
Their usage in user code should be considered a programming error, as no
memory ordering semantics were ever documented for these operations (and
therefore relying on any specific semantic would be relying on
undocumented, unportable behavior). This matches the API of the
std::atomic class in C++. Note that you can still use explicit
load/store operations to transfer a value across two Qt atomic objects,
and therefore use the memory ordering specified for the load/store
operations.
Change-Id: Iab653bad761afb8b3e3b6a967ece7b28713aa944
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
whenAll() and whenAny() create a shared context object which is
referenced by the continuation lambda. The refcount of context is only
correctly managed when it is copied non-const to the lambda's
capture list.
Fixes: QTBUG-116731
Pick-to: 6.6 6.6.0
Change-Id: I8e79e1a0dc867f69bbacf1ed873f353a18f6ad38
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This is part of our testing effort where we try enabling more tests for
Web Assembly platform on CI. Not all tests work out of box, so some of
them will require followup work.
This commmit also introduces a new mechanism of automatically renaming
files when they are added many times with the same filename to single
translation unit.
Change-Id: I620536494ea83aeb9b294c4a35ef72b51e85a38b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
The density of Q_FOREACH uses in this and some other modules is still
extremely high, too high for anyone to tackle in a short amount of
time. Even if they're not concentrated in just a few TUs, we need to
make progress on a global QT_NO_FOREACH default, so grab the nettle
and stick to our strategy:
Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from
creeping in, and whitelist the affected TUs by #undef'ing
QT_NO_FOREACH locally, at the top of each file. For TUs that are part
of a larger executable, this requires these files to be compiled
separately, so add them to NO_PCH_SOURCES (which implies
NO_UNITY_BUILD_SOURCES, too).
In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the
#undef QT_NO_FOREACH to indicate that these actually test the macro.
Task-number: QTBUG-115839
Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Fix typo so tst_qfuture on platforms without exceptions can be build
correctly.
Change-Id: I32c12effdda13da9c8669bfddd362acc1c8a14c7
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Everyone must have this by now. This test was 1193 ms of CMake time.
Since this was a PUBLIC feature, I've left it around with a constant
condition.
Change-Id: Ifbf974a4d10745b099b1fffd177754538bbff245
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This reverts commit f647375275. There are
no signed integer overflows in atomics.
For the non-atomic side, unlike the commit being reverted, we fix the
signed integer overflow by removing the "signed" part instead of the
"overflow" part, and use unsigned integer overflows instead.
Change-Id: I53335f845a1345299031fffd176f5ba479163e44
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
They aren't used because the C++11 atomics are the only atomics we've
supported since commit 9d1fab424e (5.6).
Pick-to: 6.6
Change-Id: I53335f845a1345299031fffd176f84ccd054b804
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
By the time QObject::destroyed() is emitted from ~QObject(), sender no
longer is-a SenderObject, only a QObject, so calling a SenderObject
member function on it is UB.
Says UBSan:
tst_qfuture.cpp:3854:84: runtime error: member call on address 0x60200000e550 which does not point to an object of type 'SenderObject'
0x60200000e550: note: object is of type 'QObject'
00 00 00 00 e8 3f 96 c9 51 7f 00 00 80 3e 00 00 c0 60 00 00 02 11 00 00 08 00 00 00 16 00 00 72
^~~~~~~~~~~~~~~~~~~~~~~
vptr for 'QObject'
Fix by removing the QObject::connect().
This, of course, breaks the test's WHEN, but I don't see how to keep
that WHEN without the UB. At least the THEN part is not invalidated,
and there doesn't appear to be another test that tests that destroying
objects before signal emission results in a cancelled future.
Amends 612f6999c8.
Pick-to: 6.6 6.5 6.2
Change-Id: I38ca4611c071e8fd200393b600210e36d4030bc6
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
I cannot get it to fail on my local machine
Change-Id: Iec30858df6bf5ef51a805745745cc0e98e8db03a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Add the boilerplate standalone test prelude to each test, so that they
can be opened with an IDE without the qt-cmake-standalone-test script,
but directly with qt-cmake or cmake.
Boilerplate was added using the following scripts:
https://git.qt.io/alcroito/cmake_refactor
Manual adjustments were made where the code was inserted in the wrong
location.
Task-number: QTBUG-93020
Change-Id: I28b6d3815c5f43d2c33ea65764f6f3f8f129eaf3
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>