summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/thread/qpromise.h2
-rw-r--r--tests/auto/corelib/thread/qpromise/tst_qpromise.cpp15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/corelib/thread/qpromise.h b/src/corelib/thread/qpromise.h
index 9be9526ef6..9db58ad595 100644
--- a/src/corelib/thread/qpromise.h
+++ b/src/corelib/thread/qpromise.h
@@ -46,7 +46,7 @@ public:
// Core QPromise APIs
QFuture<T> future() const { return d.future(); }
- template<typename U, typename = QtPrivate::EnableIfSameOrConvertible<U, T>>
+ template<typename U = T, typename = QtPrivate::EnableIfSameOrConvertible<U, T>>
bool addResult(U &&result, int index = -1)
{
return d.reportResult(std::forward<U>(result), index);
diff --git a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
index 6c23884b36..09332f92ef 100644
--- a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
+++ b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
@@ -24,6 +24,7 @@ private slots:
void promise();
void futureFromPromise();
void addResult();
+ void addResultWithBracedInitializer();
void addResultOutOfOrder();
#ifndef QT_NO_EXCEPTIONS
void setException();
@@ -196,6 +197,20 @@ void tst_QPromise::addResult()
}
}
+void tst_QPromise::addResultWithBracedInitializer() // QTBUG-111826
+{
+ struct MyClass
+ {
+ QString strValue;
+ int intValue = 0;
+ };
+
+ {
+ QPromise<MyClass> myPromise;
+ myPromise.addResult({"bar", 1});
+ }
+}
+
void tst_QPromise::addResultOutOfOrder()
{
// Compare results available in QFuture to expected results