summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qfuturesynchronizer.qdoc
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-06-21 10:38:00 +0200
committerMarc Mutz <marc.mutz@qt.io>2023-06-21 14:20:42 +0000
commite8dcbaaaf61ee2164db61e70a5d61d7a5b849371 (patch)
treed4d56a2fb6cc1d01b733242953cfcbf12dfcf54d /src/corelib/thread/qfuturesynchronizer.qdoc
parent77f7c3a45d83ed14dbe92ed7ae2f8ccc95d2eed1 (diff)
QFutureSynchronizer: fix aliasing problem in setFuture()
When setFuture() was handed an element of m_futures, it would hold the reference to past the clear(), which invalidates said reference. Fix by taking the future by value instead of by cref. While append() is not affected, as QList::append() already guards against aliasing, do the same change there, both for consistency as well as to optimize the common case of passing rvalues. It also means we can use the rvalue overload of QList::append(), skipping the alias analysis in the lvalue QList::append(). [ChangeLog][QtConcurrent][QFutureSynchronizer] Fixed a crash in setFuture() if the argument was already a member of QFutureSynchronizer::futures(). Pick-to: 6.6 6.5 6.2 Change-Id: Ic0b212b9f265a746df9a6beb6272a5415d131442 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/thread/qfuturesynchronizer.qdoc')
-rw-r--r--src/corelib/thread/qfuturesynchronizer.qdoc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/thread/qfuturesynchronizer.qdoc b/src/corelib/thread/qfuturesynchronizer.qdoc
index 8dd7d58c4a..7d2d16d6e9 100644
--- a/src/corelib/thread/qfuturesynchronizer.qdoc
+++ b/src/corelib/thread/qfuturesynchronizer.qdoc
@@ -38,7 +38,7 @@
*/
/*!
- \fn template <typename T> QFutureSynchronizer<T>::QFutureSynchronizer(const QFuture<T> &future)
+ \fn template <typename T> QFutureSynchronizer<T>::QFutureSynchronizer(QFuture<T> future)
Constructs a QFutureSynchronizer and begins watching \a future by calling
addFuture().
@@ -56,7 +56,7 @@
*/
/*!
- \fn template <typename T> void QFutureSynchronizer<T>::setFuture(const QFuture<T> &future)
+ \fn template <typename T> void QFutureSynchronizer<T>::setFuture(QFuture<T> future)
Sets \a future to be the only future managed by this QFutureSynchronizer.
This is a convenience function that calls waitForFinished(),
@@ -66,7 +66,7 @@
*/
/*!
- \fn template <typename T> void QFutureSynchronizer<T>::addFuture(const QFuture<T> &future)
+ \fn template <typename T> void QFutureSynchronizer<T>::addFuture(QFuture<T> future)
Adds \a future to the list of managed futures.