summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qproperty.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2020-04-29 11:53:18 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2020-04-30 19:39:42 +0200
commit709648993c1ea5f6b46ebe8bfd0f27d75c9b4e95 (patch)
treed55a7e97258fb9192f50abb85e93ba0ea4855d01 /src/corelib/kernel/qproperty.h
parent0c4bc39002763d2b0298586674a774821f52aa00 (diff)
Fix crash when using QProperty<T>::setBinding(Functor ...)
We must move the functor properly into the binding object, otherwise we end up with stale pointers as pointed out by ASAN. Change-Id: Icd84f4c113dd48e1e3e2d744abac0902cdf9339e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.h')
-rw-r--r--src/corelib/kernel/qproperty.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h
index 24aa1804f2..22313bc92e 100644
--- a/src/corelib/kernel/qproperty.h
+++ b/src/corelib/kernel/qproperty.h
@@ -316,10 +316,11 @@ public:
#ifndef Q_CLANG_QDOC
template <typename Functor>
- QPropertyBinding<T> setBinding(Functor f,
- const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION)
+ QPropertyBinding<T> setBinding(Functor &&f,
+ const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION,
+ std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr)
{
- return setBinding(Qt::makePropertyBinding(f, location));
+ return setBinding(Qt::makePropertyBinding(std::forward<Functor>(f), location));
}
#else
template <typename Functor>