Whitespace cleanup in corelib/kernel

Change-Id: If061ef0af5ced4384e20a82afcea3712fa7e45d7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Allan Sandfeld Jensen 2020-10-20 10:13:49 +02:00
parent c4245e7b8c
commit c2cf5f824a
37 changed files with 359 additions and 344 deletions

View File

@ -263,7 +263,9 @@ public:
Q_DISABLE_COPY(QAppleLogActivity) Q_DISABLE_COPY(QAppleLogActivity)
QAppleLogActivity(QAppleLogActivity &&other) QAppleLogActivity(QAppleLogActivity &&other)
: activity(qExchange(other.activity, nullptr)), state(other.state) {} : activity(qExchange(other.activity, nullptr)), state(other.state)
{
}
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QAppleLogActivity) QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QAppleLogActivity)
@ -274,7 +276,8 @@ public:
return std::move(*this); return std::move(*this);
} }
void leave() { void leave()
{
if (activity) if (activity)
os_activity_scope_leave(&state); os_activity_scope_leave(&state);
} }
@ -334,7 +337,10 @@ public:
#endif #endif
QMacNotificationObserver(const QMacNotificationObserver &other) = delete; QMacNotificationObserver(const QMacNotificationObserver &other) = delete;
QMacNotificationObserver(QMacNotificationObserver&& other) : observer(qExchange(other.observer, nullptr)) {} QMacNotificationObserver(QMacNotificationObserver &&other)
: observer(qExchange(other.observer, nullptr))
{
}
QMacNotificationObserver &operator=(const QMacNotificationObserver &other) = delete; QMacNotificationObserver &operator=(const QMacNotificationObserver &other) = delete;
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QMacNotificationObserver) QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QMacNotificationObserver)
@ -378,7 +384,8 @@ public:
~QMacKeyValueObserver() { removeObserver(); } ~QMacKeyValueObserver() { removeObserver(); }
QMacKeyValueObserver &operator=(const QMacKeyValueObserver &other) { QMacKeyValueObserver &operator=(const QMacKeyValueObserver &other)
{
QMacKeyValueObserver tmp(other); QMacKeyValueObserver tmp(other);
swap(tmp); swap(tmp);
return *this; return *this;

View File

@ -60,5 +60,4 @@ QString qAppFileName()
return appFileName; return appFileName;
} }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -350,6 +350,7 @@ public:
explicit QTimerEvent(int timerId); explicit QTimerEvent(int timerId);
~QTimerEvent(); ~QTimerEvent();
int timerId() const { return id; } int timerId() const { return id; }
protected: protected:
int id; int id;
}; };
@ -365,6 +366,7 @@ public:
bool added() const { return type() == ChildAdded; } bool added() const { return type() == ChildAdded; }
bool polished() const { return type() == ChildPolished; } bool polished() const { return type() == ChildPolished; }
bool removed() const { return type() == ChildRemoved; } bool removed() const { return type() == ChildRemoved; }
protected: protected:
QObject *c; QObject *c;
}; };
@ -387,6 +389,7 @@ public:
explicit QDeferredDeleteEvent(); explicit QDeferredDeleteEvent();
~QDeferredDeleteEvent(); ~QDeferredDeleteEvent();
int loopLevel() const { return level; } int loopLevel() const { return level; }
private: private:
int level; int level;
friend class QCoreApplication; friend class QCoreApplication;

View File

@ -61,7 +61,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
struct QCoreGlobalData { struct QCoreGlobalData
{
QCoreGlobalData(); QCoreGlobalData();
~QCoreGlobalData(); ~QCoreGlobalData();
@ -71,7 +72,5 @@ struct QCoreGlobalData {
static QCoreGlobalData *instance(); static QCoreGlobalData *instance();
}; };
QT_END_NAMESPACE QT_END_NAMESPACE
#endif // QCOREGLOBALDATA_P_H #endif // QCOREGLOBALDATA_P_H

View File

@ -212,7 +212,6 @@ QT_BEGIN_NAMESPACE
\sa isValid(), start() \sa isValid(), start()
*/ */
/*! /*!
\fn bool QElapsedTimer::operator ==(const QElapsedTimer &other) const \fn bool QElapsedTimer::operator ==(const QElapsedTimer &other) const

View File

@ -44,7 +44,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QEventLoopPrivate; class QEventLoopPrivate;
class Q_CORE_EXPORT QEventLoop : public QObject class Q_CORE_EXPORT QEventLoop : public QObject
@ -84,7 +83,6 @@ public Q_SLOTS:
Q_DECLARE_OPERATORS_FOR_FLAGS(QEventLoop::ProcessEventsFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(QEventLoop::ProcessEventsFlags)
class QEventLoopLockerPrivate; class QEventLoopLockerPrivate;
class Q_CORE_EXPORT QEventLoopLocker class Q_CORE_EXPORT QEventLoopLocker

View File

@ -43,7 +43,6 @@
static const char logTag[] = "QtCore"; static const char logTag[] = "QtCore";
Q_CORE_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) Q_CORE_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{ {
Q_UNUSED(reserved); Q_UNUSED(reserved);
@ -63,16 +62,14 @@ Q_CORE_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
_JNIEnv uenv; _JNIEnv uenv;
uenv.venv = nullptr; uenv.venv = nullptr;
if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_6) != JNI_OK) if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_6) != JNI_OK) {
{
__android_log_print(ANDROID_LOG_FATAL, logTag, "GetEnv failed"); __android_log_print(ANDROID_LOG_FATAL, logTag, "GetEnv failed");
return JNI_ERR; return JNI_ERR;
} }
JNIEnv *env = uenv.nenv; JNIEnv *env = uenv.nenv;
const jint ret = QT_PREPEND_NAMESPACE(QtAndroidPrivate::initJNI(vm, env)); const jint ret = QT_PREPEND_NAMESPACE(QtAndroidPrivate::initJNI(vm, env));
if (ret != 0) if (ret != 0) {
{
__android_log_print(ANDROID_LOG_FATAL, logTag, "initJNI failed"); __android_log_print(ANDROID_LOG_FATAL, logTag, "initJNI failed");
return ret; return ret;
} }

View File

@ -268,7 +268,8 @@ constexpr inline long double qRadiansToDegrees(long double radians)
// using integral datatypes... // using integral datatypes...
namespace QtPrivate { namespace QtPrivate {
constexpr inline quint32 qConstexprNextPowerOfTwo(quint32 v) { constexpr inline quint32 qConstexprNextPowerOfTwo(quint32 v)
{
v |= v >> 1; v |= v >> 1;
v |= v >> 2; v |= v >> 2;
v |= v >> 4; v |= v >> 4;
@ -278,7 +279,8 @@ constexpr inline quint32 qConstexprNextPowerOfTwo(quint32 v) {
return v; return v;
} }
constexpr inline quint64 qConstexprNextPowerOfTwo(quint64 v) { constexpr inline quint64 qConstexprNextPowerOfTwo(quint64 v)
{
v |= v >> 1; v |= v >> 1;
v |= v >> 2; v |= v >> 2;
v |= v >> 4; v |= v >> 4;

View File

@ -2666,7 +2666,6 @@ int QMetaEnum::value(int index) const
return -1; return -1;
} }
/*! /*!
Returns \c true if this enumerator is used as a flag; otherwise returns Returns \c true if this enumerator is used as a flag; otherwise returns
false. false.
@ -2861,7 +2860,6 @@ QMetaEnum::QMetaEnum(const QMetaObject *mobj, int index)
The enum needs to be declared with Q_ENUM. The enum needs to be declared with Q_ENUM.
*/ */
/*! /*!
\class QMetaProperty \class QMetaProperty
\inmodule QtCore \inmodule QtCore
@ -3416,7 +3414,6 @@ bool QMetaProperty::isWritable() const
return data.flags() & Writable; return data.flags() & Writable;
} }
/*! /*!
Returns \c false if the \c{Q_PROPERTY()}'s \c DESIGNABLE attribute Returns \c false if the \c{Q_PROPERTY()}'s \c DESIGNABLE attribute
is false; otherwise returns \c true. is false; otherwise returns \c true.
@ -3554,7 +3551,6 @@ bool QMetaProperty::isBindable() const
\sa QMetaObject \sa QMetaObject
*/ */
/*! /*!
\fn QMetaClassInfo::QMetaClassInfo() \fn QMetaClassInfo::QMetaClassInfo()
\internal \internal
@ -3603,7 +3599,6 @@ const char* QMetaClassInfo::value() const
our state machine and dbus. our state machine and dbus.
*/ */
/*! /*!
\macro QGenericArgument Q_ARG(Type, const Type &value) \macro QGenericArgument Q_ARG(Type, const Type &value)
\relates QMetaObject \relates QMetaObject

View File

@ -243,7 +243,9 @@ public:
inline bool isValid() const { return name() != nullptr; } inline bool isValid() const { return name() != nullptr; }
template<typename T> static QMetaEnum fromType() { template<typename T>
static QMetaEnum fromType()
{
static_assert(QtPrivate::IsQEnumHelper<T>::Value, static_assert(QtPrivate::IsQEnumHelper<T>::Value,
"QMetaEnum::fromType only works with enums declared as " "QMetaEnum::fromType only works with enums declared as "
"Q_ENUM, Q_ENUM_NS, Q_FLAG or Q_FLAG_NS"); "Q_ENUM, Q_ENUM_NS, Q_FLAG or Q_FLAG_NS");
@ -363,6 +365,7 @@ public:
const char *name() const; const char *name() const;
const char *value() const; const char *value() const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; } inline const QMetaObject *enclosingMetaObject() const { return mobj; }
private: private:
struct Data { struct Data {
enum { Size = 2 }; enum { Size = 2 };

View File

@ -210,7 +210,8 @@ struct QMetaObjectPrivate
static int indexOfConstructor(const QMetaObject *m, const QByteArray &name, static int indexOfConstructor(const QMetaObject *m, const QByteArray &name,
int argc, const QArgumentType *types); int argc, const QArgumentType *types);
Q_CORE_EXPORT static QMetaMethod signal(const QMetaObject *m, int signal_index); Q_CORE_EXPORT static QMetaMethod signal(const QMetaObject *m, int signal_index);
static inline int signalOffset(const QMetaObject *m) { static inline int signalOffset(const QMetaObject *m)
{
Q_ASSERT(m != nullptr); Q_ASSERT(m != nullptr);
int offset = 0; int offset = 0;
for (m = m->d.superdata; m; m = m->d.superdata) for (m = m->d.superdata; m; m = m->d.superdata)

View File

@ -253,8 +253,8 @@ QMetaObjectBuilder::QMetaObjectBuilder()
\sa addMetaObject() \sa addMetaObject()
*/ */
QMetaObjectBuilder::QMetaObjectBuilder QMetaObjectBuilder::QMetaObjectBuilder(const QMetaObject *prototype,
(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members) QMetaObjectBuilder::AddMembers members)
{ {
d = new QMetaObjectBuilderPrivate(); d = new QMetaObjectBuilderPrivate();
addMetaObject(prototype, members); addMetaObject(prototype, members);
@ -434,12 +434,11 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
\sa method(), methodCount(), removeMethod(), indexOfMethod() \sa method(), methodCount(), removeMethod(), indexOfMethod()
*/ */
QMetaMethodBuilder QMetaObjectBuilder::addMethod QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray &signature,
(const QByteArray& signature, const QByteArray& returnType) const QByteArray &returnType)
{ {
int index = int(d->methods.size()); int index = int(d->methods.size());
d->methods.push_back(QMetaMethodBuilderPrivate d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature, returnType));
(QMetaMethod::Method, signature, returnType));
return QMetaMethodBuilder(this, index); return QMetaMethodBuilder(this, index);
} }
@ -500,8 +499,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray &signature) QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray &signature)
{ {
int index = int(d->methods.size()); int index = int(d->methods.size());
d->methods.push_back(QMetaMethodBuilderPrivate d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Signal, signature,
(QMetaMethod::Signal, signature, QByteArray("void"), QMetaMethod::Public)); QByteArray("void"), QMetaMethod::Public));
return QMetaMethodBuilder(this, index); return QMetaMethodBuilder(this, index);
} }
@ -554,8 +553,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototy
\sa property(), propertyCount(), removeProperty(), indexOfProperty() \sa property(), propertyCount(), removeProperty(), indexOfProperty()
*/ */
QMetaPropertyBuilder QMetaObjectBuilder::addProperty QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QByteArray &name, const QByteArray &type,
(const QByteArray& name, const QByteArray& type, int notifierId) int notifierId)
{ {
int index = int(d->properties.size()); int index = int(d->properties.size());
d->properties.push_back(QMetaPropertyBuilderPrivate(name, type, notifierId)); d->properties.push_back(QMetaPropertyBuilderPrivate(name, type, notifierId));
@ -673,8 +672,8 @@ int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObject *meta)
The \a members parameter indicates which members of \a prototype The \a members parameter indicates which members of \a prototype
should be added. The default is AllMembers. should be added. The default is AllMembers.
*/ */
void QMetaObjectBuilder::addMetaObject void QMetaObjectBuilder::addMetaObject(const QMetaObject *prototype,
(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members) QMetaObjectBuilder::AddMembers members)
{ {
Q_ASSERT(prototype); Q_ASSERT(prototype);
int index; int index;
@ -1507,7 +1506,8 @@ QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
{ {
int size = buildMetaObject(d, nullptr, 0, true); int size = buildMetaObject(d, nullptr, 0, true);
if (size == -1) { if (size == -1) {
if (ok) *ok = false; if (ok)
*ok = false;
return QByteArray(); return QByteArray();
} }
@ -1516,7 +1516,8 @@ QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
char *buf = data.data(); char *buf = data.data();
memset(buf, 0, size); memset(buf, 0, size);
buildMetaObject(d, buf, size, true); buildMetaObject(d, buf, size, true);
if (ok) *ok = true; if (ok)
*ok = true;
return data; return data;
} }
@ -1662,8 +1663,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
} }
// Resolve a class name using the name reference map. // Resolve a class name using the name reference map.
static const QMetaObject *resolveClassName static const QMetaObject *resolveClassName(const QMap<QByteArray, const QMetaObject *> &references,
(const QMap<QByteArray, const QMetaObject *>& references,
const QByteArray &name) const QByteArray &name)
{ {
if (name == QByteArray("QObject")) if (name == QByteArray("QObject"))
@ -2070,7 +2070,6 @@ int QMetaMethodBuilder::revision() const
if (d) if (d)
return d->revision; return d->revision;
return 0; return 0;
} }
/*! /*!
@ -2557,7 +2556,6 @@ int QMetaPropertyBuilder::revision() const
if (d) if (d)
return d->revision; return d->revision;
return 0; return 0;
} }
/*! /*!
@ -2572,7 +2570,6 @@ void QMetaPropertyBuilder::setRevision(int revision)
d->revision = revision; d->revision = revision;
} }
/*! /*!
\class QMetaEnumBuilder \class QMetaEnumBuilder
\inmodule QtCore \inmodule QtCore

View File

@ -1491,7 +1491,6 @@ Q_DECLARE_METATYPE_TEMPLATE_2ARG(std::pair)
#define Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER(TEMPLATENAME) \ #define Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER(TEMPLATENAME) \
Q_DECLARE_SMART_POINTER_METATYPE(TEMPLATENAME) Q_DECLARE_SMART_POINTER_METATYPE(TEMPLATENAME)
QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER) QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER)
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -1500,7 +1499,6 @@ QT_BEGIN_NAMESPACE
QT_END_NAMESPACE QT_END_NAMESPACE
QT_FOR_EACH_STATIC_TYPE(Q_DECLARE_BUILTIN_METATYPE) QT_FOR_EACH_STATIC_TYPE(Q_DECLARE_BUILTIN_METATYPE)
Q_DECLARE_METATYPE(QtMetaTypePrivate::QPairVariantInterfaceImpl) Q_DECLARE_METATYPE(QtMetaTypePrivate::QPairVariantInterfaceImpl)
@ -2219,7 +2217,9 @@ public:
static constexpr QMetaTypeInterface::DtorFn getDtor() static constexpr QMetaTypeInterface::DtorFn getDtor()
{ {
if constexpr (std::is_destructible_v<S>) if constexpr (std::is_destructible_v<S>)
return [](const QMetaTypeInterface *, void *addr) { reinterpret_cast<S *>(addr)->~S(); }; return [](const QMetaTypeInterface *, void *addr) {
reinterpret_cast<S *>(addr)->~S();
};
else else
return nullptr; return nullptr;
} }
@ -2340,16 +2340,15 @@ constexpr const QMetaTypeInterface *qMetaTypeInterfaceForType()
} }
namespace detail { namespace detail {
template<typename T, typename ODR_VIOLATION_PREVENTER> template<typename T, typename ODR_VIOLATION_PREVENTER>
struct is_complete_helper { struct is_complete_helper
{
template<typename U> template<typename U>
static auto check(U *) -> std::integral_constant<bool, sizeof(U) != 0>; static auto check(U *) -> std::integral_constant<bool, sizeof(U) != 0>;
static auto check(...) -> std::false_type; static auto check(...) -> std::false_type;
using type = decltype(check(static_cast<T *>(nullptr))); using type = decltype(check(static_cast<T *>(nullptr)));
}; };
} // namespace detail
}
template <typename T, typename ODR_VIOLATION_PREVENTER> template <typename T, typename ODR_VIOLATION_PREVENTER>
struct is_complete : detail::is_complete_helper<T, ODR_VIOLATION_PREVENTER>::type {}; struct is_complete : detail::is_complete_helper<T, ODR_VIOLATION_PREVENTER>::type {};

View File

@ -161,10 +161,10 @@ public:
extern Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeGuiHelper; extern Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeGuiHelper;
extern Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeWidgetsHelper; extern Q_CORE_EXPORT const QMetaTypeModuleHelper *qMetaTypeWidgetsHelper;
namespace QtMetaTypePrivate { namespace QtMetaTypePrivate {
template<typename T> template<typename T>
struct TypeDefinition { struct TypeDefinition
{
static const bool IsAvailable = true; static const bool IsAvailable = true;
}; };

View File

@ -45,7 +45,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QUrl; class QUrl;
class QMimeDataPrivate; class QMimeDataPrivate;
@ -84,8 +83,10 @@ public:
virtual QStringList formats() const; virtual QStringList formats() const;
void clear(); void clear();
protected: protected:
virtual QVariant retrieveData(const QString &mimetype, QMetaType preferredType) const; virtual QVariant retrieveData(const QString &mimetype, QMetaType preferredType) const;
private: private:
Q_DISABLE_COPY(QMimeData) Q_DISABLE_COPY(QMimeData)
Q_DECLARE_PRIVATE(QMimeData) Q_DECLARE_PRIVATE(QMimeData)

View File

@ -109,7 +109,8 @@ static int *queuedConnectionTypes(const QMetaMethod& method)
typeIds[i] = metaType.id(); typeIds[i] = metaType.id();
if (!typeIds[i]) { if (!typeIds[i]) {
const QByteArray typeName = method.parameterTypeName(i); const QByteArray typeName = method.parameterTypeName(i);
qCWarning(lcConnect, "QObject::connect: Cannot queue arguments of type '%s'\n" qCWarning(lcConnect,
"QObject::connect: Cannot queue arguments of type '%s'\n"
"(Make sure '%s' is registered using qRegisterMetaType().)", "(Make sure '%s' is registered using qRegisterMetaType().)",
typeName.constData(), typeName.constData()); typeName.constData(), typeName.constData());
delete[] typeIds; delete[] typeIds;
@ -134,7 +135,8 @@ static int *queuedConnectionTypes(const QArgumentType *argumentTypes, int argc)
types[i] = QMetaType::fromName(type.name()).id(); types[i] = QMetaType::fromName(type.name()).id();
if (!types[i]) { if (!types[i]) {
qCWarning(lcConnect, "QObject::connect: Cannot queue arguments of type '%s'\n" qCWarning(lcConnect,
"QObject::connect: Cannot queue arguments of type '%s'\n"
"(Make sure '%s' is registered using qRegisterMetaType().)", "(Make sure '%s' is registered using qRegisterMetaType().)",
type.name().constData(), type.name().constData()); type.name().constData(), type.name().constData());
return nullptr; return nullptr;
@ -227,7 +229,8 @@ QObjectPrivate::~QObjectPrivate()
thisThreadData->deref(); thisThreadData->deref();
if (metaObject) metaObject->objectDestroyed(q_ptr); if (metaObject)
metaObject->objectDestroyed(q_ptr);
delete extraData; delete extraData;
} }
@ -2197,7 +2200,6 @@ void QObject::removeEventFilter(QObject *obj)
} }
} }
/*! /*!
\fn void QObject::destroyed(QObject *obj) \fn void QObject::destroyed(QObject *obj)
@ -2284,7 +2286,6 @@ void QObject::deleteLater()
Signals and slots Signals and slots
*****************************************************************************/ *****************************************************************************/
const char *qFlagLocation(const char *method) const char *qFlagLocation(const char *method)
{ {
QThreadData *currentThreadData = QThreadData::current(false); QThreadData *currentThreadData = QThreadData::current(false);
@ -2316,22 +2317,23 @@ static bool check_signal_macro(const QObject *sender, const char *signal,
int sigcode = extract_code(signal); int sigcode = extract_code(signal);
if (sigcode != QSIGNAL_CODE) { if (sigcode != QSIGNAL_CODE) {
if (sigcode == QSLOT_CODE) if (sigcode == QSLOT_CODE)
qCWarning(lcConnect, "QObject::%s: Attempt to %s non-signal %s::%s", qCWarning(lcConnect, "QObject::%s: Attempt to %s non-signal %s::%s", func, op,
func, op, sender->metaObject()->className(), signal+1); sender->metaObject()->className(), signal + 1);
else else
qCWarning(lcConnect, "QObject::%s: Use the SIGNAL macro to %s %s::%s", qCWarning(lcConnect, "QObject::%s: Use the SIGNAL macro to %s %s::%s", func, op,
func, op, sender->metaObject()->className(), signal); sender->metaObject()->className(), signal);
return false; return false;
} }
return true; return true;
} }
static bool check_method_code(int code, const QObject *object, static bool check_method_code(int code, const QObject *object, const char *method, const char *func)
const char *method, const char *func)
{ {
if (code != QSLOT_CODE && code != QSIGNAL_CODE) { if (code != QSLOT_CODE && code != QSIGNAL_CODE) {
qCWarning(lcConnect, "QObject::%s: Use the SLOT or SIGNAL macro to " qCWarning(lcConnect,
"%s %s::%s", func, func, object->metaObject()->className(), method); "QObject::%s: Use the SLOT or SIGNAL macro to "
"%s %s::%s",
func, func, object->metaObject()->className(), method);
return false; return false;
} }
return true; return true;
@ -2347,20 +2349,14 @@ static void err_method_notfound(const QObject *object,
} }
const char *loc = extract_location(method); const char *loc = extract_location(method);
if (strchr(method, ')') == nullptr) // common typing mistake if (strchr(method, ')') == nullptr) // common typing mistake
qCWarning(lcConnect, "QObject::%s: Parentheses expected, %s %s::%s%s%s", qCWarning(lcConnect, "QObject::%s: Parentheses expected, %s %s::%s%s%s", func, type,
func, type, object->metaObject()->className(), method+1, object->metaObject()->className(), method + 1, loc ? " in " : "", loc ? loc : "");
loc ? " in ": "", loc ? loc : "");
else else
qCWarning(lcConnect, "QObject::%s: No such %s %s::%s%s%s", qCWarning(lcConnect, "QObject::%s: No such %s %s::%s%s%s", func, type,
func, type, object->metaObject()->className(), method+1, object->metaObject()->className(), method + 1, loc ? " in " : "", loc ? loc : "");
loc ? " in ": "", loc ? loc : "");
} }
static void err_info_about_objects(const char *func, const QObject *sender, const QObject *receiver)
static void err_info_about_objects(const char * func,
const QObject * sender,
const QObject * receiver)
{ {
QString a = sender ? sender->objectName() : QString(); QString a = sender ? sender->objectName() : QString();
QString b = receiver ? receiver->objectName() : QString(); QString b = receiver ? receiver->objectName() : QString();
@ -2612,11 +2608,11 @@ static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaM
if (!(method.attributes() & QMetaMethod::Compatibility)) if (!(method.attributes() & QMetaMethod::Compatibility))
qCWarning(lcConnect, "QObject::connect: Connecting from COMPAT signal (%s::%s)", qCWarning(lcConnect, "QObject::connect: Connecting from COMPAT signal (%s::%s)",
sender->className(), signal.methodSignature().constData()); sender->className(), signal.methodSignature().constData());
} else if ((method.attributes() & QMetaMethod::Compatibility) && } else if ((method.attributes() & QMetaMethod::Compatibility)
method.methodType() == QMetaMethod::Signal) { && method.methodType() == QMetaMethod::Signal) {
qCWarning(lcConnect, "QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)", qCWarning(lcConnect, "QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)",
sender->className(), signal.methodSignature().constData(), sender->className(), signal.methodSignature().constData(), receiver->className(),
receiver->className(), method.methodSignature().constData()); method.methodSignature().constData());
} }
} }
#endif #endif
@ -2787,10 +2783,11 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
if (!QMetaObjectPrivate::checkConnectArgs(signalTypes.size(), signalTypes.constData(), if (!QMetaObjectPrivate::checkConnectArgs(signalTypes.size(), signalTypes.constData(),
methodTypes.size(), methodTypes.constData())) { methodTypes.size(), methodTypes.constData())) {
qCWarning(lcConnect, "QObject::connect: Incompatible sender/receiver arguments" qCWarning(lcConnect,
"QObject::connect: Incompatible sender/receiver arguments"
"\n %s::%s --> %s::%s", "\n %s::%s --> %s::%s",
sender->metaObject()->className(), signal, sender->metaObject()->className(), signal, receiver->metaObject()->className(),
receiver->metaObject()->className(), method); method);
return QMetaObject::Connection(nullptr); return QMetaObject::Connection(nullptr);
} }
@ -2867,17 +2864,18 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
return QMetaObject::Connection(nullptr); return QMetaObject::Connection(nullptr);
} }
if (!QMetaObject::checkConnectArgs(signal.methodSignature().constData(), method.methodSignature().constData())) { if (!QMetaObject::checkConnectArgs(signal.methodSignature().constData(),
qCWarning(lcConnect, "QObject::connect: Incompatible sender/receiver arguments" method.methodSignature().constData())) {
qCWarning(lcConnect,
"QObject::connect: Incompatible sender/receiver arguments"
"\n %s::%s --> %s::%s", "\n %s::%s --> %s::%s",
smeta->className(), signal.methodSignature().constData(), smeta->className(), signal.methodSignature().constData(), rmeta->className(),
rmeta->className(), method.methodSignature().constData()); method.methodSignature().constData());
return QMetaObject::Connection(nullptr); return QMetaObject::Connection(nullptr);
} }
int *types = nullptr; int *types = nullptr;
if ((type == Qt::QueuedConnection) if ((type == Qt::QueuedConnection) && !(types = queuedConnectionTypes(signal)))
&& !(types = queuedConnectionTypes(signal)))
return QMetaObject::Connection(nullptr); return QMetaObject::Connection(nullptr);
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
@ -3284,7 +3282,8 @@ static int methodIndexToSignalIndex(const QMetaObject **base, int signal_index)
from the sender to the receiver's slot from the sender to the receiver's slot
*/ */
QMetaObject::Connection QMetaObject::connect(const QObject *sender, int signal_index, QMetaObject::Connection QMetaObject::connect(const QObject *sender, int signal_index,
const QObject *receiver, int method_index, int type, int *types) const QObject *receiver, int method_index, int type,
int *types)
{ {
const QMetaObject *smeta = sender->metaObject(); const QMetaObject *smeta = sender->metaObject();
signal_index = methodIndexToSignalIndex(&smeta, signal_index); signal_index = methodIndexToSignalIndex(&smeta, signal_index);
@ -3613,7 +3612,8 @@ void QMetaObject::connectSlotsByName(QObject *o)
int iParen = slotSignature.indexOf('('); int iParen = slotSignature.indexOf('(');
int iLastUnderscore = slotSignature.lastIndexOf('_', iParen - 1); int iLastUnderscore = slotSignature.lastIndexOf('_', iParen - 1);
if (iLastUnderscore > 3) if (iLastUnderscore > 3)
qCWarning(lcConnectSlotsByName, "QMetaObject::connectSlotsByName: No matching signal for %s", slot); qCWarning(lcConnectSlotsByName,
"QMetaObject::connectSlotsByName: No matching signal for %s", slot);
} }
} }
} }

View File

@ -86,7 +86,8 @@ Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QRegular
const QMetaObject &mo, QList<void *> *list, Qt::FindChildOptions options); const QMetaObject &mo, QList<void *> *list, Qt::FindChildOptions options);
Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo, Qt::FindChildOptions options); Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo, Qt::FindChildOptions options);
class Q_CORE_EXPORT QObjectData { class Q_CORE_EXPORT QObjectData
{
Q_DISABLE_COPY(QObjectData) Q_DISABLE_COPY(QObjectData)
public: public:
QObjectData() = default; QObjectData() = default;
@ -113,7 +114,6 @@ public:
#endif #endif
}; };
class Q_CORE_EXPORT QObject class Q_CORE_EXPORT QObject
{ {
Q_OBJECT Q_OBJECT
@ -384,7 +384,9 @@ public:
inline QObject *parent() const { return d_ptr->parent; } inline QObject *parent() const { return d_ptr->parent; }
inline bool inherits(const char *classname) const inline bool inherits(const char *classname) const
{ return const_cast<QObject *>(this)->qt_metacast(classname) != nullptr; } {
return const_cast<QObject *>(this)->qt_metacast(classname) != nullptr;
}
public Q_SLOTS: public Q_SLOTS:
void deleteLater(); void deleteLater();
@ -497,6 +499,7 @@ public:
inline void reblock() noexcept; inline void reblock() noexcept;
inline void unblock() noexcept; inline void unblock() noexcept;
private: private:
Q_DISABLE_COPY(QSignalBlocker) Q_DISABLE_COPY(QSignalBlocker)
QObject *m_o; QObject *m_o;
@ -548,13 +551,15 @@ QSignalBlocker::~QSignalBlocker()
void QSignalBlocker::reblock() noexcept void QSignalBlocker::reblock() noexcept
{ {
if (m_o) m_o->blockSignals(true); if (m_o)
m_o->blockSignals(true);
m_inhibited = false; m_inhibited = false;
} }
void QSignalBlocker::unblock() noexcept void QSignalBlocker::unblock() noexcept
{ {
if (m_o) m_o->blockSignals(m_blocked); if (m_o)
m_o->blockSignals(m_blocked);
m_inhibited = true; m_inhibited = true;
} }

View File

@ -123,7 +123,8 @@ public:
Connection *next; Connection *next;
}; };
static SignalVector *asSignalVector(ConnectionOrSignalVector *c) { static SignalVector *asSignalVector(ConnectionOrSignalVector *c)
{
if (reinterpret_cast<quintptr>(c) & 1) if (reinterpret_cast<quintptr>(c) & 1)
return reinterpret_cast<SignalVector *>(reinterpret_cast<quintptr>(c) & ~quintptr(1u)); return reinterpret_cast<SignalVector *>(reinterpret_cast<quintptr>(c) & ~quintptr(1u));
return nullptr; return nullptr;
@ -171,7 +172,8 @@ public:
isSlotObject = false; isSlotObject = false;
} }
} }
void deref() { void deref()
{
if (!ref_.deref()) { if (!ref_.deref()) {
Q_ASSERT(!receiver.loadRelaxed()); Q_ASSERT(!receiver.loadRelaxed());
Q_ASSERT(!isSlotObject); Q_ASSERT(!isSlotObject);
@ -229,8 +231,6 @@ public:
int count() const { return static_cast<int>(allocated); } int count() const { return static_cast<int>(allocated); }
}; };
/* /*
This contains the all connections from and to an object. This contains the all connections from and to an object.
@ -278,7 +278,8 @@ public:
return signalVector.loadRelaxed()->at(signal); return signalVector.loadRelaxed()->at(signal);
} }
void resizeSignalVector(uint size) { void resizeSignalVector(uint size)
{
SignalVector *vector = this->signalVector.loadRelaxed(); SignalVector *vector = this->signalVector.loadRelaxed();
if (vector && vector->allocated > size) if (vector && vector->allocated > size)
return; return;
@ -300,7 +301,8 @@ public:
orphaned.storeRelaxed(ConnectionOrSignalVector::fromSignalVector(vector)); orphaned.storeRelaxed(ConnectionOrSignalVector::fromSignalVector(vector));
} }
} }
int signalVectorCount() const { int signalVectorCount() const
{
return signalVector.loadAcquire() ? signalVector.loadRelaxed()->count() : -1; return signalVector.loadAcquire() ? signalVector.loadRelaxed()->count() : -1;
} }
@ -324,9 +326,7 @@ public:
void addConnection(int signal, Connection *c); void addConnection(int signal, Connection *c);
static QObjectPrivate *get(QObject *o) { static QObjectPrivate *get(QObject *o) { return o->d_func(); }
return o->d_func();
}
static const QObjectPrivate *get(const QObject *o) { return o->d_func(); } static const QObjectPrivate *get(const QObject *o) { return o->d_func(); }
int signalIndex(const char *signalName, const QMetaObject **meta = nullptr) const; int signalIndex(const char *signalName, const QMetaObject **meta = nullptr) const;
@ -578,6 +578,7 @@ class QBoolBlocker
public: public:
explicit inline QBoolBlocker(bool &b, bool value = true) : block(b), reset(b) { block = value; } explicit inline QBoolBlocker(bool &b, bool value = true) : block(b), reset(b) { block = value; }
inline ~QBoolBlocker() { block = reset; } inline ~QBoolBlocker() { block = reset; }
private: private:
bool &block; bool &block;
bool reset; bool reset;

View File

@ -44,7 +44,6 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QObjectCleanupHandler : public QObject class Q_CORE_EXPORT QObjectCleanupHandler : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -848,7 +848,8 @@ public:
explicit QObjectBindableProperty(Functor &&f); explicit QObjectBindableProperty(Functor &&f);
#endif #endif
parameter_type value() const { parameter_type value() const
{
qGetBindingStorage(owner())->maybeUpdateBindingAndRegister(this); qGetBindingStorage(owner())->maybeUpdateBindingAndRegister(this);
return this->val; return this->val;
} }
@ -875,7 +876,8 @@ public:
return value(); return value();
} }
void setValue(parameter_type t) { void setValue(parameter_type t)
{
auto *bd = qGetBindingStorage(owner())->bindingData(this); auto *bd = qGetBindingStorage(owner())->bindingData(this);
if (bd) if (bd)
bd->removeBinding(); bd->removeBinding();
@ -885,7 +887,8 @@ public:
notify(bd); notify(bd);
} }
void setValue(rvalue_ref t) { void setValue(rvalue_ref t)
{
auto *bd = qGetBindingStorage(owner())->bindingData(this); auto *bd = qGetBindingStorage(owner())->bindingData(this);
if (bd) if (bd)
bd->removeBinding(); bd->removeBinding();
@ -936,7 +939,8 @@ public:
QPropertyBinding<T> setBinding(Functor f); QPropertyBinding<T> setBinding(Functor f);
#endif #endif
bool hasBinding() const { bool hasBinding() const
{
auto *bd = qGetBindingStorage(owner())->bindingData(this); auto *bd = qGetBindingStorage(owner())->bindingData(this);
return bd && bd->binding() != nullptr; return bd && bd->binding() != nullptr;
} }
@ -1003,13 +1007,15 @@ class QObjectComputedProperty : public QUntypedPropertyData
char *that = const_cast<char *>(reinterpret_cast<const char *>(this)); char *that = const_cast<char *>(reinterpret_cast<const char *>(this));
return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset)); return reinterpret_cast<Class *>(that - QtPrivate::detail::getOffset(Offset));
} }
public: public:
using value_type = T; using value_type = T;
using parameter_type = T; using parameter_type = T;
QObjectComputedProperty() = default; QObjectComputedProperty() = default;
parameter_type value() const { parameter_type value() const
{
qGetBindingStorage(owner())->maybeUpdateBindingAndRegister(this); qGetBindingStorage(owner())->maybeUpdateBindingAndRegister(this);
return (owner()->*Getter)(); return (owner()->*Getter)();
} }
@ -1055,6 +1061,7 @@ public:
auto *storage = const_cast<QBindingStorage *>(qGetBindingStorage(owner())); auto *storage = const_cast<QBindingStorage *>(qGetBindingStorage(owner()));
return *storage->bindingData(const_cast<QObjectComputedProperty *>(this), true); return *storage->bindingData(const_cast<QObjectComputedProperty *>(this), true);
} }
private: private:
}; };

View File

@ -226,7 +226,8 @@ public:
staticObserverCallback = nullptr; staticObserverCallback = nullptr;
} }
} }
void prependObserver(QPropertyObserverPointer observer) { void prependObserver(QPropertyObserverPointer observer)
{
observer.ptr->prev = const_cast<QPropertyObserver **>(&firstObserver.ptr); observer.ptr->prev = const_cast<QPropertyObserver **>(&firstObserver.ptr);
firstObserver = observer; firstObserver = observer;
} }
@ -254,7 +255,8 @@ public:
heapObservers->clear(); heapObservers->clear();
dependencyObserverCount = 0; dependencyObserverCount = 0;
} }
QPropertyObserverPointer allocateDependencyObserver() { QPropertyObserverPointer allocateDependencyObserver()
{
if (dependencyObserverCount < inlineDependencyObservers.size()) { if (dependencyObserverCount < inlineDependencyObservers.size()) {
++dependencyObserverCount; ++dependencyObserverCount;
return {&inlineDependencyObservers[dependencyObserverCount - 1]}; return {&inlineDependencyObservers[dependencyObserverCount - 1]};
@ -280,7 +282,8 @@ public:
void setError(QPropertyBindingError &&e) void setError(QPropertyBindingError &&e)
{ error = std::move(e); } { error = std::move(e); }
void detachFromProperty() { void detachFromProperty()
{
hasStaticObserver = false; hasStaticObserver = false;
hasBindingWrapper = false; hasBindingWrapper = false;
propertyDataPtr = nullptr; propertyDataPtr = nullptr;
@ -316,10 +319,10 @@ inline QPropertyObserverPointer QPropertyBindingDataPointer::firstObserver() con
{ {
if (auto *binding = bindingPtr()) if (auto *binding = bindingPtr())
return binding->firstObserver; return binding->firstObserver;
return {reinterpret_cast<QPropertyObserver*>(ptr->d_ptr & ~QtPrivate::QPropertyBindingData::FlagMask)}; return { reinterpret_cast<QPropertyObserver *>(ptr->d_ptr
& ~QtPrivate::QPropertyBindingData::FlagMask) };
} }
template<typename Class, typename T, auto Offset, auto Setter> template<typename Class, typename T, auto Offset, auto Setter>
class QObjectCompatProperty : public QPropertyData<T> class QObjectCompatProperty : public QPropertyData<T>
{ {
@ -363,7 +366,8 @@ public:
explicit QObjectCompatProperty(const T &initialValue) : QPropertyData<T>(initialValue) {} explicit QObjectCompatProperty(const T &initialValue) : QPropertyData<T>(initialValue) {}
explicit QObjectCompatProperty(T &&initialValue) : QPropertyData<T>(std::move(initialValue)) {} explicit QObjectCompatProperty(T &&initialValue) : QPropertyData<T>(std::move(initialValue)) {}
parameter_type value() const { parameter_type value() const
{
const QBindingStorage *storage = qGetBindingStorage(owner()); const QBindingStorage *storage = qGetBindingStorage(owner());
// make sure we don't register this binding as a dependency to itself // make sure we don't register this binding as a dependency to itself
if (!inBindingWrapper(storage)) if (!inBindingWrapper(storage))
@ -393,7 +397,8 @@ public:
return value(); return value();
} }
void setValue(parameter_type t) { void setValue(parameter_type t)
{
QBindingStorage *storage = qGetBindingStorage(owner()); QBindingStorage *storage = qGetBindingStorage(owner());
auto *bd = storage->bindingData(this); auto *bd = storage->bindingData(this);
// make sure we don't remove the binding if called from the bindingWrapper // make sure we don't remove the binding if called from the bindingWrapper

View File

@ -49,7 +49,8 @@ class QSignalMapperPrivate : public QObjectPrivate
{ {
Q_DECLARE_PUBLIC(QSignalMapper) Q_DECLARE_PUBLIC(QSignalMapper)
public: public:
void _q_senderDestroyed() { void _q_senderDestroyed()
{
Q_Q(QSignalMapper); Q_Q(QSignalMapper);
q->removeMappings(q->sender()); q->removeMappings(q->sender());
} }

View File

@ -1062,7 +1062,6 @@ void QVariant::clear()
Returns \nullptr if the type is QMetaType::UnknownType or doesn't exist. Returns \nullptr if the type is QMetaType::UnknownType or doesn't exist.
*/ */
/*! /*!
\fn QVariant::Type QVariant::nameToType(const char *name) \fn QVariant::Type QVariant::nameToType(const char *name)
\deprecated Use QMetaType instead \deprecated Use QMetaType instead
@ -2221,7 +2220,8 @@ static bool integralEquals(uint promotedType, const QVariant::Private *d1, const
namespace { namespace {
template<typename Numeric> template<typename Numeric>
int spaceShip(Numeric lhs, Numeric rhs) { int spaceShip(Numeric lhs, Numeric rhs)
{
bool smaller; bool smaller;
if constexpr (std::is_same_v<Numeric, QObject *>) if constexpr (std::is_same_v<Numeric, QObject *>)
smaller = std::less<QObject *>()(lhs, rhs); // can't use less all the time because of bool smaller = std::less<QObject *>()(lhs, rhs); // can't use less all the time because of bool
@ -2320,7 +2320,8 @@ static bool pointerEquals(const QVariant::Private *d1, const QVariant::Private *
return d1->get<QObject *>() == d2->get<QObject *>(); return d1->get<QObject *>() == d2->get<QObject *>();
} }
static int pointerCompare(const QVariant::Private *d1, const QVariant::Private *d2) { static int pointerCompare(const QVariant::Private *d1, const QVariant::Private *d2)
{
return spaceShip<QObject *>(d1->get<QObject *>(), d2->get<QObject *>()); return spaceShip<QObject *>(d1->get<QObject *>(), d2->get<QObject *>());
} }
#endif #endif
@ -2387,15 +2388,12 @@ std::optional<int> QVariant::compare(const QVariant &lhs, const QVariant &rhs)
return t.compare(lhs.constData(), rhs.constData()); return t.compare(lhs.constData(), rhs.constData());
} }
/*! /*!
\fn const void *QVariant::constData() const \fn const void *QVariant::constData() const
\fn const void* QVariant::data() const \fn const void* QVariant::data() const
\internal \internal
*/ */
/*! /*!
\internal \internal
*/ */
@ -2407,7 +2405,6 @@ void* QVariant::data()
return const_cast<void *>(constData()); return const_cast<void *>(constData());
} }
/*! /*!
Returns \c true if this is a null variant, false otherwise. Returns \c true if this is a null variant, false otherwise.