QProperty: add various missing std::move()s
Coverity (rightfully) complained that Functor f objects are being passed around by value, but not move()d, but copied. Add the missing std::move()s. This might allow passing move-only function objects now, but I didn't check. This is a de-pessimisation and Coverity complaint fix, as far as I'm concerned. Coverity only shows me two such issues in the file, but I found several others by looking for "Functor f", so fixed those, too. Coverity-Id: 480972 Coverity-Id: 480976 Pick-to: 6.5 Change-Id: I3866c94bbbde25d351650838e1e141ecbec38c0d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 870a3e4bc693f220bfef94f1d87f2b85072d5ba9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 82ce2315e5f730810695bd4a784682171def1f04) (cherry picked from commit caa45581ebe3a24b392d46d89d5ea6845a39e4b6)
This commit is contained in:
committed by
Qt Cherry-pick Bot
parent
b530ae6e81
commit
8bdaa41024
@@ -299,7 +299,7 @@ public:
|
||||
auto This = static_cast<QPropertyChangeHandler<Functor>*>(self);
|
||||
This->m_handler();
|
||||
})
|
||||
, m_handler(handler)
|
||||
, m_handler(std::move(handler))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ public:
|
||||
auto This = static_cast<QPropertyChangeHandler<Functor>*>(self);
|
||||
This->m_handler();
|
||||
})
|
||||
, m_handler(handler)
|
||||
, m_handler(std::move(handler))
|
||||
{
|
||||
setSource(property);
|
||||
}
|
||||
@@ -329,7 +329,7 @@ public:
|
||||
auto This = static_cast<QPropertyNotifier *>(self);
|
||||
This->m_handler();
|
||||
})
|
||||
, m_handler(handler)
|
||||
, m_handler(std::move(handler))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ public:
|
||||
auto This = static_cast<QPropertyNotifier *>(self);
|
||||
This->m_handler();
|
||||
})
|
||||
, m_handler(handler)
|
||||
, m_handler(std::move(handler))
|
||||
{
|
||||
setSource(property);
|
||||
}
|
||||
@@ -484,7 +484,7 @@ public:
|
||||
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
|
||||
{
|
||||
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
|
||||
return QPropertyChangeHandler<Functor>(*this, f);
|
||||
return QPropertyChangeHandler<Functor>(*this, std::move(f));
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
@@ -492,14 +492,14 @@ public:
|
||||
{
|
||||
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
|
||||
f();
|
||||
return onValueChanged(f);
|
||||
return onValueChanged(std::move(f));
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
QPropertyNotifier addNotifier(Functor f)
|
||||
{
|
||||
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
|
||||
return QPropertyNotifier(*this, f);
|
||||
return QPropertyNotifier(*this, std::move(f));
|
||||
}
|
||||
|
||||
const QtPrivate::QPropertyBindingData &bindingData() const { return d; }
|
||||
@@ -735,7 +735,7 @@ public:
|
||||
template<typename Functor>
|
||||
QPropertyChangeHandler<Functor> onValueChanged(Functor f) const
|
||||
{
|
||||
QPropertyChangeHandler<Functor> handler(f);
|
||||
QPropertyChangeHandler<Functor> handler(std::move(f));
|
||||
observe(&handler);
|
||||
return handler;
|
||||
}
|
||||
@@ -744,13 +744,13 @@ public:
|
||||
QPropertyChangeHandler<Functor> subscribe(Functor f) const
|
||||
{
|
||||
f();
|
||||
return onValueChanged(f);
|
||||
return onValueChanged(std::move(f));
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
QPropertyNotifier addNotifier(Functor f)
|
||||
{
|
||||
QPropertyNotifier handler(f);
|
||||
QPropertyNotifier handler(std::move(f));
|
||||
observe(&handler);
|
||||
return handler;
|
||||
}
|
||||
@@ -996,19 +996,19 @@ public:
|
||||
template<typename Functor>
|
||||
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
|
||||
{
|
||||
return QBindable<T>(aliasedProperty(), iface).onValueChanged(f);
|
||||
return QBindable<T>(aliasedProperty(), iface).onValueChanged(std::move(f));
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
QPropertyChangeHandler<Functor> subscribe(Functor f)
|
||||
{
|
||||
return QBindable<T>(aliasedProperty(), iface).subscribe(f);
|
||||
return QBindable<T>(aliasedProperty(), iface).subscribe(std::move(f));
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
QPropertyNotifier addNotifier(Functor f)
|
||||
{
|
||||
return QBindable<T>(aliasedProperty(), iface).addNotifier(f);
|
||||
return QBindable<T>(aliasedProperty(), iface).addNotifier(std::move(f));
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
@@ -1184,7 +1184,7 @@ public:
|
||||
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
|
||||
{
|
||||
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
|
||||
return QPropertyChangeHandler<Functor>(*this, f);
|
||||
return QPropertyChangeHandler<Functor>(*this, std::move(f));
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
@@ -1192,14 +1192,14 @@ public:
|
||||
{
|
||||
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
|
||||
f();
|
||||
return onValueChanged(f);
|
||||
return onValueChanged(std::move(f));
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
QPropertyNotifier addNotifier(Functor f)
|
||||
{
|
||||
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
|
||||
return QPropertyNotifier(*this, f);
|
||||
return QPropertyNotifier(*this, std::move(f));
|
||||
}
|
||||
|
||||
const QtPrivate::QPropertyBindingData &bindingData() const
|
||||
@@ -1320,7 +1320,7 @@ public:
|
||||
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
|
||||
{
|
||||
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
|
||||
return QPropertyChangeHandler<Functor>(*this, f);
|
||||
return QPropertyChangeHandler<Functor>(*this, std::move(f));
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
@@ -1328,14 +1328,14 @@ public:
|
||||
{
|
||||
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
|
||||
f();
|
||||
return onValueChanged(f);
|
||||
return onValueChanged(std::move(f));
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
QPropertyNotifier addNotifier(Functor f)
|
||||
{
|
||||
static_assert(std::is_invocable_v<Functor>, "Functor callback must be callable without any parameters");
|
||||
return QPropertyNotifier(*this, f);
|
||||
return QPropertyNotifier(*this, std::move(f));
|
||||
}
|
||||
|
||||
QtPrivate::QPropertyBindingData &bindingData() const
|
||||
|
||||
Reference in New Issue
Block a user