summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-07-27 17:34:10 +0200
committerLars Knoll <lars.knoll@qt.io>2020-08-24 00:19:30 +0200
commit700e6341e51f5e6f45303fab3d0a84a3eb249eba (patch)
tree0d2d876937b99e3de9d92582dff5ba56ced9f8c4
parent369cb1470d06b01934e616757ad98db2bb9ebb20 (diff)
Pass QMetaType by value
Now that QMetaType is not refcounted anymore, we can and should pass it by value. Change-Id: I848db65070713762f548ca949097c27783aacad4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/kernel/qmetatype.cpp10
-rw-r--r--src/corelib/kernel/qmetatype.h6
-rw-r--r--src/corelib/kernel/qproperty.cpp2
-rw-r--r--src/corelib/kernel/qproperty.h5
-rw-r--r--src/corelib/kernel/qproperty_p.h2
-rw-r--r--src/corelib/kernel/qpropertyprivate.h8
-rw-r--r--src/corelib/kernel/qvariant.h2
7 files changed, 17 insertions, 18 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 42c5c7cb32..20d5c9130f 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -806,7 +806,7 @@ void QMetaType::unregisterMetaType(QMetaType type)
Returns the QMetaType corresponding to the type in the template parameter.
*/
-/*! \fn bool operator==(const QMetaType &a, const QMetaType &b)
+/*! \fn bool operator==(QMetaType a, QMetaType b)
\since 5.15
\relates QMetaType
\overload
@@ -815,7 +815,7 @@ void QMetaType::unregisterMetaType(QMetaType type)
as the QMetaType \a b, otherwise returns \c false.
*/
-/*! \fn bool operator!=(const QMetaType &a, const QMetaType &b)
+/*! \fn bool operator!=(QMetaType a, QMetaType b)
\since 5.15
\relates QMetaType
\overload
@@ -1714,7 +1714,7 @@ static QMetaEnum metaEnumFromType(QMetaType t)
}
#endif
-static bool convertFromEnum(const QMetaType &fromType, const void *from, QMetaType toType, void *to)
+static bool convertFromEnum(QMetaType fromType, const void *from, QMetaType toType, void *to)
{
qlonglong ll;
if (fromType.flags() & QMetaType::IsUnsignedEnumeration) {
@@ -1966,7 +1966,7 @@ static bool convertToAssociativeIterable(QMetaType fromType, const void *from, v
#ifndef QT_BOOTSTRAPPED
-static bool canConvertMetaObject(const QMetaType &fromType, const QMetaType &toType)
+static bool canConvertMetaObject(QMetaType fromType, QMetaType toType)
{
if ((fromType.flags() & QMetaType::PointerToQObject) && (toType.flags() & QMetaType::PointerToQObject)) {
return fromType.metaObject()->inherits(toType.metaObject()) ||
@@ -2128,7 +2128,7 @@ bool QMetaType::convert(QMetaType fromType, const void *from, QMetaType toType,
\sa convert(), QSequentialIterable, Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(), QAssociativeIterable,
Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE()
*/
-bool QMetaType::canConvert(const QMetaType &fromType, const QMetaType &toType)
+bool QMetaType::canConvert(QMetaType fromType, QMetaType toType)
{
int fromTypeId = fromType.id();
int toTypeId = toType.id();
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index b72b2f69be..bf76f39a2a 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -438,8 +438,8 @@ public:
static QMetaType fromType();
static QMetaType fromName(QByteArrayView name);
- friend bool operator==(const QMetaType &a, const QMetaType &b) { return a.id() == b.id(); }
- friend bool operator!=(const QMetaType &a, const QMetaType &b) { return !(a == b); }
+ friend bool operator==(QMetaType a, QMetaType b) { return a.id() == b.id(); }
+ friend bool operator!=(QMetaType a, QMetaType b) { return !(a == b); }
public:
@@ -538,7 +538,7 @@ public:
#endif
static bool convert(QMetaType fromType, const void *from, QMetaType toType, void *to);
- static bool canConvert(const QMetaType &fromType, const QMetaType &toType);
+ static bool canConvert(QMetaType fromType, QMetaType toType);
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_6_0
static bool convert(const void *from, int fromTypeId, void *to, int toTypeId)
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp
index cbb2954a98..926ccdd8de 100644
--- a/src/corelib/kernel/qproperty.cpp
+++ b/src/corelib/kernel/qproperty.cpp
@@ -150,7 +150,7 @@ bool QPropertyBindingPrivate::evaluateIfDirtyAndReturnTrueIfValueChanged()
QUntypedPropertyBinding::QUntypedPropertyBinding() = default;
-QUntypedPropertyBinding::QUntypedPropertyBinding(const QMetaType &metaType, QUntypedPropertyBinding::BindingEvaluationFunction function,
+QUntypedPropertyBinding::QUntypedPropertyBinding(QMetaType metaType, QUntypedPropertyBinding::BindingEvaluationFunction function,
const QPropertyBindingSourceLocation &location)
{
d = new QPropertyBindingPrivate(metaType, std::move(function), std::move(location));
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h
index ae7f3a5050..1064180c27 100644
--- a/src/corelib/kernel/qproperty.h
+++ b/src/corelib/kernel/qproperty.h
@@ -43,7 +43,6 @@
#include <QtCore/qglobal.h>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QString>
-#include <QtCore/qmetatype.h>
#include <functional>
#include <type_traits>
#include <variant>
@@ -123,7 +122,7 @@ public:
using BindingEvaluationFunction = QtPrivate::QPropertyBindingFunction;
QUntypedPropertyBinding();
- QUntypedPropertyBinding(const QMetaType &metaType, BindingEvaluationFunction function, const QPropertyBindingSourceLocation &location);
+ QUntypedPropertyBinding(QMetaType metaType, BindingEvaluationFunction function, const QPropertyBindingSourceLocation &location);
QUntypedPropertyBinding(QUntypedPropertyBinding &&other);
QUntypedPropertyBinding(const QUntypedPropertyBinding &other);
QUntypedPropertyBinding &operator=(const QUntypedPropertyBinding &other);
@@ -151,7 +150,7 @@ class QPropertyBinding : public QUntypedPropertyBinding
struct BindingAdaptor
{
Functor impl;
- bool operator()(const QMetaType &/*metaType*/, void *dataPtr)
+ bool operator()(QMetaType /*metaType*/, void *dataPtr)
{
PropertyType *propertyPtr = static_cast<PropertyType *>(dataPtr);
PropertyType newValue = impl();
diff --git a/src/corelib/kernel/qproperty_p.h b/src/corelib/kernel/qproperty_p.h
index 159c652657..1ddb3dd453 100644
--- a/src/corelib/kernel/qproperty_p.h
+++ b/src/corelib/kernel/qproperty_p.h
@@ -166,7 +166,7 @@ public:
// public because the auto-tests access it, too.
size_t dependencyObserverCount = 0;
- QPropertyBindingPrivate(const QMetaType &metaType, QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction,
+ QPropertyBindingPrivate(QMetaType metaType, QUntypedPropertyBinding::BindingEvaluationFunction evaluationFunction,
const QPropertyBindingSourceLocation &location)
: isBool(metaType.id() == QMetaType::Bool)
, evaluationFunction(std::move(evaluationFunction))
diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h
index e65ab324fa..ab8c96b17f 100644
--- a/src/corelib/kernel/qpropertyprivate.h
+++ b/src/corelib/kernel/qpropertyprivate.h
@@ -54,6 +54,7 @@
#include <QtCore/qglobal.h>
#include <QtCore/QExplicitlySharedDataPointer>
#include <QtCore/qtaggedpointer.h>
+#include <QtCore/qmetatype.h>
#include <functional>
@@ -63,14 +64,13 @@ class QUntypedPropertyBinding;
class QPropertyBindingPrivate;
using QPropertyBindingPrivatePtr = QExplicitlySharedDataPointer<QPropertyBindingPrivate>;
struct QPropertyBasePointer;
-class QMetaType;
namespace QtPrivate {
// writes binding result into dataPtr
-using QPropertyBindingFunction = std::function<bool(const QMetaType &metaType, void *dataPtr)>;
+using QPropertyBindingFunction = std::function<bool(QMetaType metaType, void *dataPtr)>;
-using QPropertyGuardFunction = bool(*)(const QMetaType &, void *dataPtr,
+using QPropertyGuardFunction = bool(*)(QMetaType, void *dataPtr,
QPropertyBindingFunction, void *owner);
using QPropertyObserverCallback = void (*)(void *, void *);
@@ -242,7 +242,7 @@ struct QPropertyGuardFunctionHelper
template<typename T, typename Class, auto Guard>
struct QPropertyGuardFunctionHelper<T, Class, Guard, false>
{
- static auto guard(const QMetaType &metaType, void *dataPtr,
+ static auto guard(const QMetaType metaType, void *dataPtr,
QPropertyBindingFunction eval, void *owner) -> bool
{
T t = T();
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index e9509e637a..ae4c26ed7a 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -443,7 +443,7 @@ class Q_CORE_EXPORT QVariant
quintptr packedType : sizeof(QMetaType) * 8 - 2;
Private() noexcept : is_shared(false), is_null(true), packedType(0) {}
- explicit Private(const QMetaType &type) noexcept : is_shared(false), is_null(false)
+ explicit Private(QMetaType type) noexcept : is_shared(false), is_null(false)
{
quintptr mt = quintptr(type.d_ptr);
Q_ASSERT((mt & 0x3) == 0);