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

@ -262,19 +262,22 @@ 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)
QAppleLogActivity&& enter() QAppleLogActivity &&enter()
{ {
if (activity) if (activity)
os_activity_scope_enter(static_cast<os_activity_t>(*this), &state); os_activity_scope_enter(static_cast<os_activity_t>(*this), &state);
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);
} }
@ -333,10 +336,13 @@ 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)
void swap(QMacNotificationObserver &other) noexcept void swap(QMacNotificationObserver &other) noexcept
@ -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

@ -120,7 +120,7 @@ public:
static int exec(); static int exec();
static void processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents); static void processEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
static void processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime); static void processEvents(QEventLoop::ProcessEventsFlags flags, int maxtime);
static void exit(int retcode=0); static void exit(int retcode = 0);
static bool sendEvent(QObject *receiver, QEvent *event); static bool sendEvent(QObject *receiver, QEvent *event);
static void postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority); static void postEvent(QObject *receiver, QEvent *event, int priority = Qt::NormalEventPriority);
@ -211,7 +211,7 @@ private:
#ifndef QT_NO_QOBJECT #ifndef QT_NO_QOBJECT
friend class QEventDispatcherUNIXPrivate; friend class QEventDispatcherUNIXPrivate;
friend class QCocoaEventDispatcherPrivate; friend class QCocoaEventDispatcherPrivate;
friend bool qt_sendSpontaneousEvent(QObject*, QEvent*); friend bool qt_sendSpontaneousEvent(QObject *, QEvent *);
#endif #endif
friend Q_CORE_EXPORT QString qAppName(); friend Q_CORE_EXPORT QString qAppName();
friend class QClassFactory; friend class QClassFactory;

View File

@ -51,14 +51,13 @@ QString qAppFileName()
static QString appFileName; static QString appFileName;
if (appFileName.isEmpty()) { if (appFileName.isEmpty()) {
QCFType<CFURLRef> bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle())); QCFType<CFURLRef> bundleURL(CFBundleCopyExecutableURL(CFBundleGetMainBundle()));
if(bundleURL) { if (bundleURL) {
QCFString cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle)); QCFString cfPath(CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle));
if(cfPath) if (cfPath)
appFileName = cfPath; appFileName = cfPath;
} }
} }
return appFileName; return appFileName;
} }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -347,9 +347,10 @@ private:
class Q_CORE_EXPORT QTimerEvent : public QEvent class Q_CORE_EXPORT QTimerEvent : public QEvent
{ {
public: 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;
}; };
@ -359,12 +360,13 @@ class QObject;
class Q_CORE_EXPORT QChildEvent : public QEvent class Q_CORE_EXPORT QChildEvent : public QEvent
{ {
public: public:
QChildEvent( Type type, QObject *child ); QChildEvent(Type type, QObject *child);
~QChildEvent(); ~QChildEvent();
QObject *child() const { return c; } QObject *child() const { return c; }
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

@ -68,7 +68,7 @@ bool QElapsedTimer::isMonotonic() noexcept
return true; return true;
} }
static mach_timebase_info_data_t info = {0,0}; static mach_timebase_info_data_t info = { 0, 0 };
static qint64 absoluteToNSecs(qint64 cpuTime) static qint64 absoluteToNSecs(qint64 cpuTime)
{ {
if (info.denom == 0) if (info.denom == 0)

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

@ -71,7 +71,7 @@ public:
QJNIEnvironmentPrivate(); QJNIEnvironmentPrivate();
~QJNIEnvironmentPrivate(); ~QJNIEnvironmentPrivate();
JNIEnv *operator->(); JNIEnv *operator->();
operator JNIEnv*() const; operator JNIEnv *() const;
static jclass findClass(const char *className, JNIEnv *env = nullptr); static jclass findClass(const char *className, JNIEnv *env = nullptr);
private: private:
@ -252,12 +252,12 @@ private:
QSharedPointer<QJNIObjectData> d; QSharedPointer<QJNIObjectData> d;
}; };
inline bool operator==(const QJNIObjectPrivate&obj1, const QJNIObjectPrivate&obj2) inline bool operator==(const QJNIObjectPrivate &obj1, const QJNIObjectPrivate &obj2)
{ {
return obj1.isSameObject(obj2); return obj1.isSameObject(obj2);
} }
inline bool operator!=(const QJNIObjectPrivate&obj1, const QJNIObjectPrivate&obj2) inline bool operator!=(const QJNIObjectPrivate &obj1, const QJNIObjectPrivate &obj2)
{ {
return !obj1.isSameObject(obj2); return !obj1.isSameObject(obj2);
} }

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

@ -229,7 +229,7 @@ inline qreal qFastCos(qreal x)
constexpr inline float qDegreesToRadians(float degrees) constexpr inline float qDegreesToRadians(float degrees)
{ {
return degrees * float(M_PI/180); return degrees * float(M_PI / 180);
} }
constexpr inline double qDegreesToRadians(double degrees) constexpr inline double qDegreesToRadians(double degrees)
@ -250,7 +250,7 @@ constexpr inline double qDegreesToRadians(T degrees)
constexpr inline float qRadiansToDegrees(float radians) constexpr inline float qRadiansToDegrees(float radians)
{ {
return radians * float(180/M_PI); return radians * float(180 / M_PI);
} }
constexpr inline double qRadiansToDegrees(double radians) constexpr inline double qRadiansToDegrees(double radians)
@ -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

@ -2662,11 +2662,10 @@ int QMetaEnum::value(int index) const
if (!mobj) if (!mobj)
return 0; return 0;
if (index >= 0 && index < int(data.keyCount())) if (index >= 0 && index < int(data.keyCount()))
return mobj->d.data[data.data() + 2*index + 1]; return mobj->d.data[data.data() + 2 * index + 1];
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.
@ -2731,7 +2730,7 @@ int QMetaEnum::keyToValue(const char *key, bool *ok) const
const char *s = key + qstrlen(key); const char *s = key + qstrlen(key);
while (s > key && *s != ':') while (s > key && *s != ':')
--s; --s;
if (s > key && *(s-1)==':') { if (s > key && *(s - 1) == ':') {
scope = s - key - 1; scope = s - key - 1;
key += scope + 2; key += scope + 2;
} }
@ -2741,7 +2740,7 @@ int QMetaEnum::keyToValue(const char *key, bool *ok) const
&& strcmp(key, rawStringData(mobj, mobj->d.data[data.data() + 2*i])) == 0) { && strcmp(key, rawStringData(mobj, mobj->d.data[data.data() + 2*i])) == 0) {
if (ok != nullptr) if (ok != nullptr)
*ok = true; *ok = true;
return mobj->d.data[data.data() + 2*i + 1]; return mobj->d.data[data.data() + 2 * i + 1];
} }
} }
return -1; return -1;
@ -2755,13 +2754,13 @@ int QMetaEnum::keyToValue(const char *key, bool *ok) const
\sa isFlag(), valueToKeys() \sa isFlag(), valueToKeys()
*/ */
const char* QMetaEnum::valueToKey(int value) const const char *QMetaEnum::valueToKey(int value) const
{ {
if (!mobj) if (!mobj)
return nullptr; return nullptr;
for (int i = 0; i < int(data.keyCount()); ++i) for (int i = 0; i < int(data.keyCount()); ++i)
if (value == (int)mobj->d.data[data.data() + 2*i + 1]) if (value == (int)mobj->d.data[data.data() + 2 * i + 1])
return rawStringData(mobj, mobj->d.data[data.data() + 2*i]); return rawStringData(mobj, mobj->d.data[data.data() + 2 * i]);
return nullptr; return nullptr;
} }
@ -2797,7 +2796,7 @@ int QMetaEnum::keysToValue(const char *keys, bool *ok) const
const char *s = key + qstrlen(key); const char *s = key + qstrlen(key);
while (s > key && *s != ':') while (s > key && *s != ':')
--s; --s;
if (s > key && *(s-1)==':') { if (s > key && *(s - 1) == ':') {
scope = s - key - 1; scope = s - key - 1;
key += scope + 2; key += scope + 2;
} }
@ -2833,12 +2832,12 @@ QByteArray QMetaEnum::valueToKeys(int value) const
int v = value; int v = value;
// reverse iterate to ensure values like Qt::Dialog=0x2|Qt::Window are processed first. // reverse iterate to ensure values like Qt::Dialog=0x2|Qt::Window are processed first.
for (int i = data.keyCount() - 1; i >= 0; --i) { for (int i = data.keyCount() - 1; i >= 0; --i) {
int k = mobj->d.data[data.data() + 2*i + 1]; int k = mobj->d.data[data.data() + 2 * i + 1];
if ((k != 0 && (v & k) == k ) || (k == value)) { if ((k != 0 && (v & k) == k) || (k == value)) {
v = v & ~k; v = v & ~k;
if (!keys.isEmpty()) if (!keys.isEmpty())
keys.prepend('|'); keys.prepend('|');
keys.prepend(stringData(mobj, mobj->d.data[data.data() + 2*i])); keys.prepend(stringData(mobj, mobj->d.data[data.data() + 2 * i]));
} }
} }
return keys; return keys;
@ -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
@ -2977,7 +2975,7 @@ QMetaType QMetaProperty::metaType() const
int QMetaProperty::Data::index(const QMetaObject *mobj) const int QMetaProperty::Data::index(const QMetaObject *mobj) const
{ {
return (d - mobj->d.data - priv(mobj->d.data)->propertyData)/Size; return (d - mobj->d.data - priv(mobj->d.data)->propertyData) / Size;
} }
/*! /*!
@ -3092,14 +3090,14 @@ QMetaProperty::QMetaProperty(const QMetaObject *mobj, int index)
const char *colon = strrchr(enum_name, ':'); const char *colon = strrchr(enum_name, ':');
// ':' will always appear in pairs // ':' will always appear in pairs
Q_ASSERT(colon <= enum_name || *(colon-1) == ':'); Q_ASSERT(colon <= enum_name || *(colon - 1) == ':');
if (colon > enum_name) { if (colon > enum_name) {
int len = colon-enum_name-1; int len = colon - enum_name - 1;
scope_buffer = (char *)malloc(len+1); scope_buffer = (char *)malloc(len + 1);
memcpy(scope_buffer, enum_name, len); memcpy(scope_buffer, enum_name, len);
scope_buffer[len] = '\0'; scope_buffer[len] = '\0';
scope_name = scope_buffer; scope_name = scope_buffer;
enum_name = colon+1; enum_name = colon + 1;
} }
const QMetaObject *scope = nullptr; const QMetaObject *scope = nullptr;
@ -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
@ -3582,7 +3578,7 @@ const char *QMetaClassInfo::name() const
\sa name() \sa name()
*/ */
const char* QMetaClassInfo::value() const const char *QMetaClassInfo::value() const
{ {
if (!mobj) if (!mobj)
return nullptr; return nullptr;
@ -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

@ -235,15 +235,17 @@ public:
const char *scope() const; const char *scope() const;
int keyToValue(const char *key, bool *ok = nullptr) const; int keyToValue(const char *key, bool *ok = nullptr) const;
const char* valueToKey(int value) const; const char *valueToKey(int value) const;
int keysToValue(const char * keys, bool *ok = nullptr) const; int keysToValue(const char *keys, bool *ok = nullptr) const;
QByteArray valueToKeys(int value) const; QByteArray valueToKeys(int value) const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; } inline const QMetaObject *enclosingMetaObject() const { return mobj; }
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

@ -72,7 +72,7 @@ enum PropertyFlags {
Resettable = 0x00000004, Resettable = 0x00000004,
EnumOrFlag = 0x00000008, EnumOrFlag = 0x00000008,
Alias = 0x00000010, Alias = 0x00000010,
//Reserved for future usage = 0x00000020, // Reserved for future usage = 0x00000020,
StdCppSet = 0x00000100, StdCppSet = 0x00000100,
Constant = 0x00000400, Constant = 0x00000400,
Final = 0x00000800, Final = 0x00000800,
@ -88,7 +88,7 @@ enum MethodFlags {
AccessPrivate = 0x00, AccessPrivate = 0x00,
AccessProtected = 0x01, AccessProtected = 0x01,
AccessPublic = 0x02, AccessPublic = 0x02,
AccessMask = 0x03, //mask AccessMask = 0x03, // mask
MethodMethod = 0x00, MethodMethod = 0x00,
MethodSignal = 0x04, MethodSignal = 0x04,
@ -174,7 +174,7 @@ struct QMetaObjectPrivate
// revision 8 is Qt 5.12: It adds the enum name to QMetaEnum // revision 8 is Qt 5.12: It adds the enum name to QMetaEnum
// revision 9 is Qt 6.0: It adds the metatype of properties and methods // revision 9 is Qt 6.0: It adds the metatype of properties and methods
enum { OutputRevision = 9 }; // Used by moc, qmetaobjectbuilder and qdbus enum { OutputRevision = 9 }; // Used by moc, qmetaobjectbuilder and qdbus
enum { IntsPerMethod = QMetaMethod::Data::Size}; enum { IntsPerMethod = QMetaMethod::Data::Size };
enum { IntsPerEnum = QMetaEnum::Data::Size }; enum { IntsPerEnum = QMetaEnum::Data::Size };
enum { IntsPerProperty = QMetaProperty::Data::Size }; enum { IntsPerProperty = QMetaProperty::Data::Size };
@ -210,11 +210,12 @@ 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)
offset += reinterpret_cast<const QMetaObjectPrivate*>(m->d.data)->signalCount; offset += reinterpret_cast<const QMetaObjectPrivate *>(m->d.data)->signalCount;
return offset; return offset;
} }
Q_CORE_EXPORT static int absoluteSignalCount(const QMetaObject *m); Q_CORE_EXPORT static int absoluteSignalCount(const QMetaObject *m);
@ -227,7 +228,7 @@ struct QMetaObjectPrivate
static QList<QByteArray> parameterTypeNamesFromSignature(const char *signature); static QList<QByteArray> parameterTypeNamesFromSignature(const char *signature);
#ifndef QT_NO_QOBJECT #ifndef QT_NO_QOBJECT
//defined in qobject.cpp // defined in qobject.cpp
enum DisconnectType { DisconnectAll, DisconnectOne }; enum DisconnectType { DisconnectAll, DisconnectOne };
static void memberIndexes(const QObject *obj, const QMetaMethod &member, static void memberIndexes(const QObject *obj, const QMetaMethod &member,
int *signalIndex, int *methodIndex); int *signalIndex, int *methodIndex);

View File

@ -186,7 +186,7 @@ Q_DECLARE_TYPEINFO(QMetaPropertyBuilderPrivate, Q_MOVABLE_TYPE);
class QMetaEnumBuilderPrivate class QMetaEnumBuilderPrivate
{ {
public: public:
QMetaEnumBuilderPrivate(const QByteArray& _name) QMetaEnumBuilderPrivate(const QByteArray &_name)
: name(_name), enumName(_name), isFlag(false), isScoped(false) : name(_name), enumName(_name), isFlag(false), isScoped(false)
{ {
} }
@ -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);
@ -285,7 +285,7 @@ QByteArray QMetaObjectBuilder::className() const
\sa className(), setSuperClass() \sa className(), setSuperClass()
*/ */
void QMetaObjectBuilder::setClassName(const QByteArray& name) void QMetaObjectBuilder::setClassName(const QByteArray &name)
{ {
d->className = name; d->className = name;
} }
@ -418,7 +418,7 @@ int QMetaObjectBuilder::relatedMetaObjectCount() const
\sa method(), methodCount(), removeMethod(), indexOfMethod() \sa method(), methodCount(), removeMethod(), indexOfMethod()
*/ */
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature) QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray &signature)
{ {
int index = int(d->methods.size()); int index = int(d->methods.size());
d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature)); d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
@ -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);
} }
@ -454,7 +453,7 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod
\sa method(), methodCount(), removeMethod(), indexOfMethod() \sa method(), methodCount(), removeMethod(), indexOfMethod()
*/ */
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype) QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod &prototype)
{ {
QMetaMethodBuilder method; QMetaMethodBuilder method;
if (prototype.methodType() == QMetaMethod::Method) if (prototype.methodType() == QMetaMethod::Method)
@ -482,7 +481,7 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype)
\sa addMethod(), addSignal(), indexOfSlot() \sa addMethod(), addSignal(), indexOfSlot()
*/ */
QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature) QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray &signature)
{ {
int index = int(d->methods.size()); int index = int(d->methods.size());
d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature)); d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
@ -497,11 +496,11 @@ QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
\sa addMethod(), addSlot(), indexOfSignal() \sa addMethod(), addSlot(), indexOfSignal()
*/ */
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);
} }
@ -514,7 +513,7 @@ QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
\sa constructor(), constructorCount(), removeConstructor() \sa constructor(), constructorCount(), removeConstructor()
\sa indexOfConstructor() \sa indexOfConstructor()
*/ */
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature) QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray &signature)
{ {
int index = int(d->constructors.size()); int index = int(d->constructors.size());
d->constructors.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature, d->constructors.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature,
@ -533,7 +532,7 @@ QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signatur
\sa constructor(), constructorCount(), removeConstructor() \sa constructor(), constructorCount(), removeConstructor()
\sa indexOfConstructor() \sa indexOfConstructor()
*/ */
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototype) QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod &prototype)
{ {
Q_ASSERT(prototype.methodType() == QMetaMethod::Constructor); Q_ASSERT(prototype.methodType() == QMetaMethod::Constructor);
QMetaMethodBuilder ctor = addConstructor(prototype.methodSignature()); QMetaMethodBuilder ctor = addConstructor(prototype.methodSignature());
@ -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));
@ -570,7 +569,7 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty
\sa property(), propertyCount(), removeProperty(), indexOfProperty() \sa property(), propertyCount(), removeProperty(), indexOfProperty()
*/ */
QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& prototype) QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty &prototype)
{ {
QMetaPropertyBuilder property = addProperty(prototype.name(), prototype.typeName()); QMetaPropertyBuilder property = addProperty(prototype.name(), prototype.typeName());
property.setReadable(prototype.isReadable()); property.setReadable(prototype.isReadable());
@ -604,7 +603,7 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot
\sa enumerator(), enumeratorCount(), removeEnumerator() \sa enumerator(), enumeratorCount(), removeEnumerator()
\sa indexOfEnumerator() \sa indexOfEnumerator()
*/ */
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name) QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray &name)
{ {
int index = int(d->enumerators.size()); int index = int(d->enumerators.size());
d->enumerators.push_back(QMetaEnumBuilderPrivate(name)); d->enumerators.push_back(QMetaEnumBuilderPrivate(name));
@ -620,7 +619,7 @@ QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
\sa enumerator(), enumeratorCount(), removeEnumerator() \sa enumerator(), enumeratorCount(), removeEnumerator()
\sa indexOfEnumerator() \sa indexOfEnumerator()
*/ */
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum& prototype) QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum &prototype)
{ {
QMetaEnumBuilder en = addEnumerator(prototype.name()); QMetaEnumBuilder en = addEnumerator(prototype.name());
en.setEnumName(prototype.enumName()); en.setEnumName(prototype.enumName());
@ -639,7 +638,7 @@ QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum& prototype)
\sa classInfoCount(), classInfoName(), classInfoValue(), removeClassInfo() \sa classInfoCount(), classInfoName(), classInfoValue(), removeClassInfo()
\sa indexOfClassInfo() \sa indexOfClassInfo()
*/ */
int QMetaObjectBuilder::addClassInfo(const QByteArray& name, const QByteArray& value) int QMetaObjectBuilder::addClassInfo(const QByteArray &name, const QByteArray &value)
{ {
int index = d->classInfoNames.size(); int index = d->classInfoNames.size();
d->classInfoNames += name; d->classInfoNames += name;
@ -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;
@ -948,7 +947,7 @@ void QMetaObjectBuilder::removeRelatedMetaObject(int index)
\sa method(), methodCount(), addMethod(), removeMethod() \sa method(), methodCount(), addMethod(), removeMethod()
*/ */
int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature) int QMetaObjectBuilder::indexOfMethod(const QByteArray &signature)
{ {
QByteArray sig = QMetaObject::normalizedSignature(signature); QByteArray sig = QMetaObject::normalizedSignature(signature);
for (const auto &method : d->methods) { for (const auto &method : d->methods) {
@ -964,7 +963,7 @@ int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
\sa indexOfMethod(), indexOfSlot() \sa indexOfMethod(), indexOfSlot()
*/ */
int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature) int QMetaObjectBuilder::indexOfSignal(const QByteArray &signature)
{ {
QByteArray sig = QMetaObject::normalizedSignature(signature); QByteArray sig = QMetaObject::normalizedSignature(signature);
for (const auto &method : d->methods) { for (const auto &method : d->methods) {
@ -980,7 +979,7 @@ int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
\sa indexOfMethod(), indexOfSignal() \sa indexOfMethod(), indexOfSignal()
*/ */
int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature) int QMetaObjectBuilder::indexOfSlot(const QByteArray &signature)
{ {
QByteArray sig = QMetaObject::normalizedSignature(signature); QByteArray sig = QMetaObject::normalizedSignature(signature);
for (const auto &method : d->methods) { for (const auto &method : d->methods) {
@ -996,7 +995,7 @@ int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
\sa constructor(), constructorCount(), addConstructor(), removeConstructor() \sa constructor(), constructorCount(), addConstructor(), removeConstructor()
*/ */
int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature) int QMetaObjectBuilder::indexOfConstructor(const QByteArray &signature)
{ {
QByteArray sig = QMetaObject::normalizedSignature(signature); QByteArray sig = QMetaObject::normalizedSignature(signature);
for (const auto &constructor : d->constructors) { for (const auto &constructor : d->constructors) {
@ -1012,7 +1011,7 @@ int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
\sa property(), propertyCount(), addProperty(), removeProperty() \sa property(), propertyCount(), addProperty(), removeProperty()
*/ */
int QMetaObjectBuilder::indexOfProperty(const QByteArray& name) int QMetaObjectBuilder::indexOfProperty(const QByteArray &name)
{ {
for (const auto &property : d->properties) { for (const auto &property : d->properties) {
if (name == property.name) if (name == property.name)
@ -1027,7 +1026,7 @@ int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
\sa enumertor(), enumeratorCount(), addEnumerator(), removeEnumerator() \sa enumertor(), enumeratorCount(), addEnumerator(), removeEnumerator()
*/ */
int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name) int QMetaObjectBuilder::indexOfEnumerator(const QByteArray &name)
{ {
for (const auto &enumerator : d->enumerators) { for (const auto &enumerator : d->enumerators) {
if (name == enumerator.name) if (name == enumerator.name)
@ -1043,7 +1042,7 @@ int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name)
\sa classInfoName(), classInfoValue(), classInfoCount(), addClassInfo() \sa classInfoName(), classInfoValue(), classInfoCount(), addClassInfo()
\sa removeClassInfo() \sa removeClassInfo()
*/ */
int QMetaObjectBuilder::indexOfClassInfo(const QByteArray& name) int QMetaObjectBuilder::indexOfClassInfo(const QByteArray &name)
{ {
for (int index = 0; index < d->classInfoNames.size(); ++index) { for (int index = 0; index < d->classInfoNames.size(); ++index) {
if (name == d->classInfoNames[index]) if (name == d->classInfoNames[index])
@ -1107,7 +1106,7 @@ static void writeString(char *out, int i, const QByteArray &str,
int offset = offsetOfStringdataMember + stringdataOffset; int offset = offsetOfStringdataMember + stringdataOffset;
uint offsetLen[2] = { uint(offset), uint(size) }; uint offsetLen[2] = { uint(offset), uint(size) };
memcpy(out + 2 * i * sizeof(uint), &offsetLen, 2*sizeof(uint)); memcpy(out + 2 * i * sizeof(uint), &offsetLen, 2 * sizeof(uint));
memcpy(out + offset, str.constData(), size); memcpy(out + offset, str.constData(), size);
out[offsetOfStringdataMember + stringdataOffset + size] = '\0'; out[offsetOfStringdataMember + stringdataOffset + size] = '\0';
@ -1121,13 +1120,13 @@ static void writeString(char *out, int i, const QByteArray &str,
// moc (see generator.cpp). // moc (see generator.cpp).
void QMetaStringTable::writeBlob(char *out) const void QMetaStringTable::writeBlob(char *out) const
{ {
Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (preferredAlignment()-1))); Q_ASSERT(!(reinterpret_cast<quintptr>(out) & (preferredAlignment() - 1)));
int offsetOfStringdataMember = int(m_entries.size() * 2 * sizeof(uint)); int offsetOfStringdataMember = int(m_entries.size() * 2 * sizeof(uint));
int stringdataOffset = 0; int stringdataOffset = 0;
// qt_metacast expects the first string in the string table to be the class name. // qt_metacast expects the first string in the string table to be the class name.
writeString(out, /*index*/0, m_className, offsetOfStringdataMember, stringdataOffset); writeString(out, /*index*/ 0, m_className, offsetOfStringdataMember, stringdataOffset);
for (Entries::ConstIterator it = m_entries.constBegin(), end = m_entries.constEnd(); for (Entries::ConstIterator it = m_entries.constBegin(), end = m_entries.constEnd();
it != end; ++it) { it != end; ++it) {
@ -1452,8 +1451,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
types++; types++;
} }
} }
for (const auto &constructor: d->constructors) { for (const auto &constructor : d->constructors) {
for (const auto &parameterType: constructor.parameterTypes()) { for (const auto &parameterType : constructor.parameterTypes()) {
QMetaType mt = QMetaType::fromName(parameterType); QMetaType mt = QMetaType::fromName(parameterType);
*types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt); *types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt);
types++; types++;
@ -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;
} }
@ -1586,7 +1587,7 @@ void QMetaObjectBuilder::setStaticMetacallFunction
\sa deserialize() \sa deserialize()
*/ */
void QMetaObjectBuilder::serialize(QDataStream& stream) const void QMetaObjectBuilder::serialize(QDataStream &stream) const
{ {
int index; int index;
@ -1662,9 +1663,8 @@ 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"))
return &QObject::staticMetaObject; return &QObject::staticMetaObject;
@ -1930,7 +1930,7 @@ QByteArray QMetaMethodBuilder::returnType() const
\sa returnType(), parameterTypes(), signature() \sa returnType(), parameterTypes(), signature()
*/ */
void QMetaMethodBuilder::setReturnType(const QByteArray& value) void QMetaMethodBuilder::setReturnType(const QByteArray &value)
{ {
QMetaMethodBuilderPrivate *d = d_func(); QMetaMethodBuilderPrivate *d = d_func();
if (d) if (d)
@ -1970,7 +1970,7 @@ QList<QByteArray> QMetaMethodBuilder::parameterNames() const
\sa parameterNames() \sa parameterNames()
*/ */
void QMetaMethodBuilder::setParameterNames(const QList<QByteArray>& value) void QMetaMethodBuilder::setParameterNames(const QList<QByteArray> &value)
{ {
QMetaMethodBuilderPrivate *d = d_func(); QMetaMethodBuilderPrivate *d = d_func();
if (d) if (d)
@ -1996,7 +1996,7 @@ QByteArray QMetaMethodBuilder::tag() const
\sa setTag() \sa setTag()
*/ */
void QMetaMethodBuilder::setTag(const QByteArray& value) void QMetaMethodBuilder::setTag(const QByteArray &value)
{ {
QMetaMethodBuilderPrivate *d = d_func(); QMetaMethodBuilderPrivate *d = d_func();
if (d) if (d)
@ -2070,7 +2070,6 @@ int QMetaMethodBuilder::revision() const
if (d) if (d)
return d->revision; return d->revision;
return 0; return 0;
} }
/*! /*!
@ -2177,7 +2176,7 @@ QMetaMethodBuilder QMetaPropertyBuilder::notifySignal() const
\sa hasNotifySignal(), notifySignal(), removeNotifySignal() \sa hasNotifySignal(), notifySignal(), removeNotifySignal()
*/ */
void QMetaPropertyBuilder::setNotifySignal(const QMetaMethodBuilder& value) void QMetaPropertyBuilder::setNotifySignal(const QMetaMethodBuilder &value)
{ {
QMetaPropertyBuilderPrivate *d = d_func(); QMetaPropertyBuilderPrivate *d = d_func();
if (d) { if (d) {
@ -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
@ -2740,7 +2737,7 @@ int QMetaEnumBuilder::value(int index) const
\sa keyCount(), key(), value(), removeKey() \sa keyCount(), key(), value(), removeKey()
*/ */
int QMetaEnumBuilder::addKey(const QByteArray& name, int value) int QMetaEnumBuilder::addKey(const QByteArray &name, int value)
{ {
QMetaEnumBuilderPrivate *d = d_func(); QMetaEnumBuilderPrivate *d = d_func();
if (d) { if (d) {

View File

@ -1179,11 +1179,11 @@ struct QMetaTypeIdQObject<T*, QMetaType::PointerToQObject>
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
if (const int id = metatype_id.loadAcquire()) if (const int id = metatype_id.loadAcquire())
return id; return id;
const char * const cName = T::staticMetaObject.className(); const char *const cName = T::staticMetaObject.className();
QByteArray typeName; QByteArray typeName;
typeName.reserve(int(strlen(cName)) + 1); typeName.reserve(int(strlen(cName)) + 1);
typeName.append(cName).append('*'); typeName.append(cName).append('*');
const int newId = qRegisterNormalizedMetaType<T*>(typeName); const int newId = qRegisterNormalizedMetaType<T *>(typeName);
metatype_id.storeRelease(newId); metatype_id.storeRelease(newId);
return newId; return newId;
} }
@ -1201,7 +1201,7 @@ struct QMetaTypeIdQObject<T, QMetaType::IsGadget>
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
if (const int id = metatype_id.loadAcquire()) if (const int id = metatype_id.loadAcquire())
return id; return id;
const char * const cName = T::staticMetaObject.className(); const char *const cName = T::staticMetaObject.className();
const int newId = qRegisterNormalizedMetaType<T>(cName); const int newId = qRegisterNormalizedMetaType<T>(cName);
metatype_id.storeRelease(newId); metatype_id.storeRelease(newId);
return newId; return newId;
@ -1220,11 +1220,11 @@ struct QMetaTypeIdQObject<T*, QMetaType::PointerToGadget>
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
if (const int id = metatype_id.loadAcquire()) if (const int id = metatype_id.loadAcquire())
return id; return id;
const char * const cName = T::staticMetaObject.className(); const char *const cName = T::staticMetaObject.className();
QByteArray typeName; QByteArray typeName;
typeName.reserve(int(strlen(cName)) + 1); typeName.reserve(int(strlen(cName)) + 1);
typeName.append(cName).append('*'); typeName.append(cName).append('*');
const int newId = qRegisterNormalizedMetaType<T*>(typeName); const int newId = qRegisterNormalizedMetaType<T *>(typeName);
metatype_id.storeRelease(newId); metatype_id.storeRelease(newId);
return newId; return newId;
} }
@ -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)
@ -1753,7 +1751,7 @@ private:
{ {
last = x; last = x;
if (output) if (output)
*(output-1) = x; *(output - 1) = x;
} }
constexpr void appendStr(const char *x) constexpr void appendStr(const char *x)
@ -2052,7 +2050,7 @@ constexpr auto typenameHelper()
} else { } else {
t1Name = typenameHelper<T1>(); t1Name = typenameHelper<T1>();
} }
if constexpr (bool (QMetaTypeId2<T2>::IsBuiltIn) ) { if constexpr (bool(QMetaTypeId2<T2>::IsBuiltIn)) {
t2Name = QMetaTypeId2<T2>::nameAsArray; t2Name = QMetaTypeId2<T2>::nameAsArray;
} else { } else {
t2Name = typenameHelper<T2>(); t2Name = typenameHelper<T2>();
@ -2064,7 +2062,7 @@ constexpr auto typenameHelper()
std::array<char, length + 1> result {}; std::array<char, length + 1> result {};
constexpr auto prefix = "std::pair<"; constexpr auto prefix = "std::pair<";
int currentLength = 0; int currentLength = 0;
for (; currentLength < int(sizeof("std::pair<")-1); ++currentLength) for (; currentLength < int(sizeof("std::pair<") - 1); ++currentLength)
result[currentLength] = prefix[currentLength]; result[currentLength] = prefix[currentLength];
for (int i = 0; i < int(t1Len); ++currentLength, ++i) for (int i = 0; i < int(t1Len); ++currentLength, ++i)
result[currentLength] = t1Name[i]; result[currentLength] = t1Name[i];
@ -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

@ -96,10 +96,10 @@ QAbstractDynamicMetaObject::~QAbstractDynamicMetaObject()
{ {
} }
static int *queuedConnectionTypes(const QMetaMethod& method) static int *queuedConnectionTypes(const QMetaMethod &method)
{ {
const auto parameterCount = method.parameterCount(); const auto parameterCount = method.parameterCount();
int *typeIds = new int [parameterCount + 1]; int *typeIds = new int[parameterCount + 1];
Q_CHECK_PTR(typeIds); Q_CHECK_PTR(typeIds);
for (int i = 0; i < parameterCount; ++i) { for (int i = 0; i < parameterCount; ++i) {
const QMetaType metaType = method.parameterMetaType(i); const QMetaType metaType = method.parameterMetaType(i);
@ -109,10 +109,11 @@ 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;
return nullptr; return nullptr;
} }
} }
@ -123,7 +124,7 @@ static int *queuedConnectionTypes(const QMetaMethod& method)
static int *queuedConnectionTypes(const QArgumentType *argumentTypes, int argc) static int *queuedConnectionTypes(const QArgumentType *argumentTypes, int argc)
{ {
QScopedArrayPointer<int> types(new int [argc + 1]); QScopedArrayPointer<int> types(new int[argc + 1]);
for (int i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {
const QArgumentType &type = argumentTypes[i]; const QArgumentType &type = argumentTypes[i];
if (type.type()) if (type.type())
@ -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;
} }
@ -595,7 +598,7 @@ QMetaCallEvent::~QMetaCallEvent()
if (t[i].isValid() && d.args_[i]) if (t[i].isValid() && d.args_[i])
t[i].destroy(d.args_[i]); t[i].destroy(d.args_[i]);
} }
if (reinterpret_cast<void*>(d.args_) != reinterpret_cast<void*>(prealloc_)) if (reinterpret_cast<void *>(d.args_) != reinterpret_cast<void *>(prealloc_))
free(d.args_); free(d.args_);
} }
if (d.slotObj_) if (d.slotObj_)
@ -1087,7 +1090,7 @@ QObjectPrivate::Connection::~Connection()
if (ownArgumentTypes) { if (ownArgumentTypes) {
const int *v = argumentTypes.loadRelaxed(); const int *v = argumentTypes.loadRelaxed();
if (v != &DIRECT_CONNECTION_ONLY) if (v != &DIRECT_CONNECTION_ONLY)
delete [] v; delete[] v;
} }
if (isSlotObject) if (isSlotObject)
slotObj->destroyIfLastRef(); slotObj->destroyIfLastRef();
@ -1277,13 +1280,13 @@ bool QObject::event(QEvent *e)
{ {
switch (e->type()) { switch (e->type()) {
case QEvent::Timer: case QEvent::Timer:
timerEvent((QTimerEvent*)e); timerEvent((QTimerEvent *)e);
break; break;
case QEvent::ChildAdded: case QEvent::ChildAdded:
case QEvent::ChildPolished: case QEvent::ChildPolished:
case QEvent::ChildRemoved: case QEvent::ChildRemoved:
childEvent((QChildEvent*)e); childEvent((QChildEvent *)e);
break; break;
case QEvent::DeferredDelete: case QEvent::DeferredDelete:
@ -2101,7 +2104,7 @@ void QObjectPrivate::setParent_helper(QObject *o)
return; return;
} }
parent->d_func()->children.append(q); parent->d_func()->children.append(q);
if(sendChildEvents && parent->d_func()->receiveChildEvents) { if (sendChildEvents && parent->d_func()->receiveChildEvents) {
if (!isWidget) { if (!isWidget) {
QChildEvent e(QEvent::ChildAdded, q); QChildEvent e(QEvent::ChildAdded, q);
QCoreApplication::sendEvent(parent, &e); QCoreApplication::sendEvent(parent, &e);
@ -2168,7 +2171,7 @@ void QObject::installEventFilter(QObject *obj)
d->extraData = new QObjectPrivate::ExtraData; d->extraData = new QObjectPrivate::ExtraData;
// clean up unused items in the list // clean up unused items in the list
d->extraData->eventFilters.removeAll((QObject*)nullptr); d->extraData->eventFilters.removeAll((QObject *)nullptr);
d->extraData->eventFilters.removeAll(obj); d->extraData->eventFilters.removeAll(obj);
d->extraData->eventFilters.prepend(obj); d->extraData->eventFilters.prepend(obj);
} }
@ -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);
@ -2299,7 +2300,7 @@ static int extract_code(const char *member)
return (((int)(*member) - '0') & 0x3); return (((int)(*member) - '0') & 0x3);
} }
static const char * extract_location(const char *member) static const char *extract_location(const char *member)
{ {
if (QThreadData::current()->flaggedSignatures.contains(member)) { if (QThreadData::current()->flaggedSignatures.contains(member)) {
// signature includes location information after the first null-terminator // signature includes location information after the first null-terminator
@ -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;
@ -2346,21 +2348,15 @@ static void err_method_notfound(const QObject *object,
case QSIGNAL_CODE: type = "signal"; break; case QSIGNAL_CODE: type = "signal"; break;
} }
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();
@ -2489,7 +2485,7 @@ int QObject::receivers(const char *signal) const
int signal_index = d->signalIndex(signal); int signal_index = d->signalIndex(signal);
if (signal_index < 0) { if (signal_index < 0) {
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
err_method_notfound(this, signal-1, "receivers"); err_method_notfound(this, signal - 1, "receivers");
#endif #endif
return 0; return 0;
} }
@ -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
@ -2699,9 +2695,9 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
if (sender == nullptr || receiver == nullptr || signal == nullptr || method == nullptr) { if (sender == nullptr || receiver == nullptr || signal == nullptr || method == nullptr) {
qCWarning(lcConnect, "QObject::connect: Cannot connect %s::%s to %s::%s", qCWarning(lcConnect, "QObject::connect: Cannot connect %s::%s to %s::%s",
sender ? sender->metaObject()->className() : "(nullptr)", sender ? sender->metaObject()->className() : "(nullptr)",
(signal && *signal) ? signal+1 : "(nullptr)", (signal && *signal) ? signal + 1 : "(nullptr)",
receiver ? receiver->metaObject()->className() : "(nullptr)", receiver ? receiver->metaObject()->className() : "(nullptr)",
(method && *method) ? method+1 : "(nullptr)"); (method && *method) ? method + 1 : "(nullptr)");
return QMetaObject::Connection(nullptr); return QMetaObject::Connection(nullptr);
} }
QByteArray tmp_signal_name; QByteArray tmp_signal_name;
@ -2710,7 +2706,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
return QMetaObject::Connection(nullptr); return QMetaObject::Connection(nullptr);
const QMetaObject *smeta = sender->metaObject(); const QMetaObject *smeta = sender->metaObject();
const char *signal_arg = signal; const char *signal_arg = signal;
++signal; //skip code ++signal; // skip code
QArgumentTypeArray signalTypes; QArgumentTypeArray signalTypes;
Q_ASSERT(QMetaObjectPrivate::get(smeta)->revision >= 7); Q_ASSERT(QMetaObjectPrivate::get(smeta)->revision >= 7);
QByteArray signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes); QByteArray signalName = QMetaObjectPrivate::decodeMethodSignature(signal, signalTypes);
@ -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);
} }
@ -2842,7 +2839,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
sender ? sender->metaObject()->className() : "(nullptr)", sender ? sender->metaObject()->className() : "(nullptr)",
signal.methodSignature().constData(), signal.methodSignature().constData(),
receiver ? receiver->metaObject()->className() : "(nullptr)", receiver ? receiver->metaObject()->className() : "(nullptr)",
method.methodSignature().constData() ); method.methodSignature().constData());
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
@ -3065,7 +3063,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
} }
if (res) { if (res) {
if (!signal) if (!signal)
const_cast<QObject*>(sender)->disconnectNotify(QMetaMethod()); const_cast<QObject *>(sender)->disconnectNotify(QMetaMethod());
} }
return res; return res;
} }
@ -3115,7 +3113,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
} }
} }
if (method.mobj) { if (method.mobj) {
if(method.methodType() == QMetaMethod::Constructor) { if (method.methodType() == QMetaMethod::Constructor) {
qCWarning(lcConnect, "QObject::disconnect: cannot use constructor as argument %s::%s", qCWarning(lcConnect, "QObject::disconnect: cannot use constructor as argument %s::%s",
receiver->metaObject()->className(), method.methodSignature().constData()); receiver->metaObject()->className(), method.methodSignature().constData());
return false; return false;
@ -3125,7 +3123,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
// Reconstructing SIGNAL() macro result for signal.methodSignature() string // Reconstructing SIGNAL() macro result for signal.methodSignature() string
QByteArray signalSignature; QByteArray signalSignature;
if (signal.mobj) { if (signal.mobj) {
signalSignature.reserve(signal.methodSignature().size()+1); signalSignature.reserve(signal.methodSignature().size() + 1);
signalSignature.append((char)(QSIGNAL_CODE + '0')); signalSignature.append((char)(QSIGNAL_CODE + '0'));
signalSignature.append(signal.methodSignature()); signalSignature.append(signal.methodSignature());
} }
@ -3159,7 +3157,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
// QMetaObjectPrivate::disconnect() doesn't call disconnectNotify() // QMetaObjectPrivate::disconnect() doesn't call disconnectNotify()
// per connection in this case. Call it once now, with an invalid // per connection in this case. Call it once now, with an invalid
// QMetaMethod as argument, as documented. // QMetaMethod as argument, as documented.
const_cast<QObject*>(sender)->disconnectNotify(signal); const_cast<QObject *>(sender)->disconnectNotify(signal);
} }
return true; return true;
} }
@ -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);
@ -3555,7 +3554,7 @@ void QMetaObject::connectSlotsByName(QObject *o)
// ...we check each object in our list, ... // ...we check each object in our list, ...
bool foundIt = false; bool foundIt = false;
for(int j = 0; j < list.count(); ++j) { for (int j = 0; j < list.count(); ++j) {
const QObject *co = list.at(j); const QObject *co = list.at(j);
const QByteArray coName = co->objectName().toLatin1(); const QByteArray coName = co->objectName().toLatin1();
@ -3611,9 +3610,10 @@ void QMetaObject::connectSlotsByName(QObject *o)
} else if (!(mo->method(i).attributes() & QMetaMethod::Cloned)) { } else if (!(mo->method(i).attributes() & QMetaMethod::Cloned)) {
// check if the slot has the following signature: "on_..._...(..." // check if the slot has the following signature: "on_..._...(..."
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);
} }
} }
} }
@ -3633,14 +3633,14 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
argumentTypes = &DIRECT_CONNECTION_ONLY; argumentTypes = &DIRECT_CONNECTION_ONLY;
if (!c->argumentTypes.testAndSetOrdered(nullptr, argumentTypes)) { if (!c->argumentTypes.testAndSetOrdered(nullptr, argumentTypes)) {
if (argumentTypes != &DIRECT_CONNECTION_ONLY) if (argumentTypes != &DIRECT_CONNECTION_ONLY)
delete [] argumentTypes; delete[] argumentTypes;
argumentTypes = c->argumentTypes.loadRelaxed(); argumentTypes = c->argumentTypes.loadRelaxed();
} }
} }
if (argumentTypes == &DIRECT_CONNECTION_ONLY) // cannot activate if (argumentTypes == &DIRECT_CONNECTION_ONLY) // cannot activate
return; return;
int nargs = 1; // include return type int nargs = 1; // include return type
while (argumentTypes[nargs-1]) while (argumentTypes[nargs - 1])
++nargs; ++nargs;
QBasicMutexLocker locker(signalSlotLock(c->receiver.loadRelaxed())); QBasicMutexLocker locker(signalSlotLock(c->receiver.loadRelaxed()));
@ -3665,7 +3665,7 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
if (nargs > 1) { if (nargs > 1) {
for (int n = 1; n < nargs; ++n) for (int n = 1; n < nargs; ++n)
types[n] = QMetaType(argumentTypes[n-1]); types[n] = QMetaType(argumentTypes[n - 1]);
for (int n = 1; n < nargs; ++n) for (int n = 1; n < nargs; ++n)
args[n] = types[n].create(argv[n]); args[n] = types[n].create(argv[n]);
@ -3891,7 +3891,7 @@ void QMetaObject::activate(QObject *sender, int signalOffset, int local_signal_i
doActivate<true>(sender, signal_index, argv); doActivate<true>(sender, signal_index, argv);
else else
doActivate<false>(sender, signal_index, argv); doActivate<false>(sender, signal_index, argv);
} }
/*! /*!
\internal \internal
@ -3962,7 +3962,7 @@ int QObjectPrivate::signalIndex(const char *signalName,
bool QObject::setProperty(const char *name, const QVariant &value) bool QObject::setProperty(const char *name, const QVariant &value)
{ {
Q_D(QObject); Q_D(QObject);
const QMetaObject* meta = metaObject(); const QMetaObject *meta = metaObject();
if (!name || !meta) if (!name || !meta)
return false; return false;
@ -4017,7 +4017,7 @@ bool QObject::setProperty(const char *name, const QVariant &value)
QVariant QObject::property(const char *name) const QVariant QObject::property(const char *name) const
{ {
Q_D(const QObject); Q_D(const QObject);
const QMetaObject* meta = metaObject(); const QMetaObject *meta = metaObject();
if (!name || !meta) if (!name || !meta)
return QVariant(); return QVariant();
@ -5168,7 +5168,7 @@ QMetaObject::Connection::Connection(const QMetaObject::Connection &other) : d_pt
/*! /*!
Assigns \a other to this connection and returns a reference to this connection. Assigns \a other to this connection and returns a reference to this connection.
*/ */
QMetaObject::Connection& QMetaObject::Connection::operator=(const QMetaObject::Connection& other) QMetaObject::Connection &QMetaObject::Connection::operator=(const QMetaObject::Connection &other)
{ {
if (other.d_ptr != d_ptr) { if (other.d_ptr != d_ptr) {
if (d_ptr) if (d_ptr)

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;
@ -101,7 +102,7 @@ public:
uint isDeletingChildren : 1; uint isDeletingChildren : 1;
uint sendChildEvents : 1; uint sendChildEvents : 1;
uint receiveChildEvents : 1; uint receiveChildEvents : 1;
uint isWindow : 1; //for QWindow uint isWindow : 1; // for QWindow
uint deleteLaterCalled : 1; uint deleteLaterCalled : 1;
uint unused : 24; uint unused : 24;
int postedEvents; int postedEvents;
@ -113,7 +114,6 @@ public:
#endif #endif
}; };
class Q_CORE_EXPORT QObject class Q_CORE_EXPORT QObject
{ {
Q_OBJECT Q_OBJECT
@ -122,7 +122,7 @@ class Q_CORE_EXPORT QObject
Q_DECLARE_PRIVATE(QObject) Q_DECLARE_PRIVATE(QObject)
public: public:
Q_INVOKABLE explicit QObject(QObject *parent=nullptr); Q_INVOKABLE explicit QObject(QObject *parent = nullptr);
virtual ~QObject(); virtual ~QObject();
virtual bool event(QEvent *event); virtual bool event(QEvent *event);
@ -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();
@ -392,7 +394,7 @@ public Q_SLOTS:
protected: protected:
QObject *sender() const; QObject *sender() const;
int senderSignalIndex() const; int senderSignalIndex() const;
int receivers(const char* signal) const; int receivers(const char *signal) const;
bool isSignalConnected(const QMetaMethod &signal) const; bool isSignalConnected(const QMetaMethod &signal) const;
virtual void timerEvent(QTimerEvent *event); virtual void timerEvent(QTimerEvent *event);
@ -497,9 +499,10 @@ 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;
bool m_blocked; bool m_blocked;
bool m_inhibited; bool m_inhibited;
}; };
@ -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

@ -107,7 +107,7 @@ public:
QList<QByteArray> propertyNames; QList<QByteArray> propertyNames;
QList<QVariant> propertyValues; QList<QVariant> propertyValues;
QList<int> runningTimers; QList<int> runningTimers;
QList<QPointer<QObject> > eventFilters; QList<QPointer<QObject>> eventFilters;
QString objectName; QString objectName;
}; };
@ -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;
@ -569,15 +569,16 @@ private:
ushort method_relative_; ushort method_relative_;
} d; } d;
// preallocate enough space for three arguments // preallocate enough space for three arguments
alignas(void *) char prealloc_[3*sizeof(void*) + 3*sizeof(QMetaType)]; alignas(void *) char prealloc_[3 * sizeof(void *) + 3 * sizeof(QMetaType)];
}; };
class QBoolBlocker class QBoolBlocker
{ {
Q_DISABLE_COPY_MOVE(QBoolBlocker) Q_DISABLE_COPY_MOVE(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

@ -91,12 +91,12 @@ QObjectCleanupHandler::~QObjectCleanupHandler()
\sa remove() \sa remove()
*/ */
QObject *QObjectCleanupHandler::add(QObject* object) QObject *QObjectCleanupHandler::add(QObject *object)
{ {
if (!object) if (!object)
return nullptr; return nullptr;
connect(object, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*))); connect(object, SIGNAL(destroyed(QObject *)), this, SLOT(objectDestroyed(QObject *)));
cleanupObjects.insert(0, object); cleanupObjects.insert(0, object);
return object; return object;
} }
@ -112,7 +112,7 @@ void QObjectCleanupHandler::remove(QObject *object)
int index; int index;
if ((index = cleanupObjects.indexOf(object)) != -1) { if ((index = cleanupObjects.indexOf(object)) != -1) {
cleanupObjects.removeAt(index); cleanupObjects.removeAt(index);
disconnect(object, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*))); disconnect(object, SIGNAL(destroyed(QObject *)), this, SLOT(objectDestroyed(QObject *)));
} }
} }

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
@ -53,7 +52,7 @@ public:
QObjectCleanupHandler(); QObjectCleanupHandler();
~QObjectCleanupHandler(); ~QObjectCleanupHandler();
QObject* add(QObject* object); QObject *add(QObject *object);
void remove(QObject *object); void remove(QObject *object);
bool isEmpty() const; bool isEmpty() const;
void clear(); void clear();

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;
@ -309,17 +312,17 @@ inline void QPropertyBindingDataPointer::fixupFirstObserverAfterMove() const
if (ptr->d_ptr & QtPrivate::QPropertyBindingData::BindingBit) if (ptr->d_ptr & QtPrivate::QPropertyBindingData::BindingBit)
return; // nothing to do if the observer is stored in the binding return; // nothing to do if the observer is stored in the binding
if (auto observer = firstObserver()) if (auto observer = firstObserver())
observer.ptr->prev = reinterpret_cast<QPropertyObserver**>(&(ptr->d_ptr)); observer.ptr->prev = reinterpret_cast<QPropertyObserver **>(&(ptr->d_ptr));
} }
inline QPropertyObserverPointer QPropertyBindingDataPointer::firstObserver() const inline QPropertyObserverPointer QPropertyBindingDataPointer::firstObserver() const
{ {
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

@ -134,13 +134,13 @@ public:
QTagPreservingPointerToPointer<T, Tag> &operator=(T **ptr) QTagPreservingPointerToPointer<T, Tag> &operator=(T **ptr)
{ {
d = reinterpret_cast<quintptr*>(ptr); d = reinterpret_cast<quintptr *>(ptr);
return *this; return *this;
} }
QTagPreservingPointerToPointer<T, Tag> &operator=(QTaggedPointer<T, Tag> *ptr) QTagPreservingPointerToPointer<T, Tag> &operator=(QTaggedPointer<T, Tag> *ptr)
{ {
d = reinterpret_cast<quintptr*>(ptr); d = reinterpret_cast<quintptr *>(ptr);
return *this; return *this;
} }

View File

@ -493,7 +493,7 @@ void *QSharedMemory::data()
\sa attach(), create() \sa attach(), create()
*/ */
const void* QSharedMemory::constData() const const void *QSharedMemory::constData() const
{ {
Q_D(const QSharedMemory); Q_D(const QSharedMemory);
return d->memory; return d->memory;

View File

@ -183,7 +183,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
// grab the memory // grab the memory
memory = shmat(id, nullptr, (mode == QSharedMemory::ReadOnly ? SHM_RDONLY : 0)); memory = shmat(id, nullptr, (mode == QSharedMemory::ReadOnly ? SHM_RDONLY : 0));
if ((void*) - 1 == memory) { if ((void *)-1 == memory) {
memory = nullptr; memory = nullptr;
setErrorString(QLatin1String("QSharedMemory::attach (shmat)")); setErrorString(QLatin1String("QSharedMemory::attach (shmat)"));
return false; return false;

View File

@ -102,7 +102,7 @@ HANDLE QSharedMemoryPrivate::handle()
return 0; return 0;
} }
hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false,
reinterpret_cast<const wchar_t*>(nativeKey.utf16())); reinterpret_cast<const wchar_t *>(nativeKey.utf16()));
if (!hand) { if (!hand) {
setErrorString(function); setErrorString(function);
return 0; return 0;

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());
} }
@ -61,7 +62,7 @@ public:
auto it = mappedValues.find(sender); auto it = mappedValues.find(sender);
if (it != mappedValues.end()) if (it != mappedValues.end())
Q_EMIT (q->*signal)(*it); Q_EMIT(q->*signal)(*it);
} }
void emitMappedValues(QObject *sender) void emitMappedValues(QObject *sender)
@ -73,7 +74,7 @@ public:
QHash<QObject *, int> intHash; QHash<QObject *, int> intHash;
QHash<QObject *, QString> stringHash; QHash<QObject *, QString> stringHash;
QHash<QObject *, QObject*> objectHash; QHash<QObject *, QObject *> objectHash;
}; };
/*! /*!

View File

@ -136,9 +136,9 @@ static QString standardLibraryErrorString(int errorCode)
QString QSystemError::string(ErrorScope errorScope, int errorCode) QString QSystemError::string(ErrorScope errorScope, int errorCode)
{ {
switch(errorScope) { switch (errorScope) {
case NativeError: case NativeError:
#if defined (Q_OS_WIN) #if defined(Q_OS_WIN)
return windowsErrorString(errorCode); return windowsErrorString(errorCode);
#endif // else unix: native and standard library are the same #endif // else unix: native and standard library are the same
case StandardLibraryError: case StandardLibraryError:

View File

@ -82,7 +82,7 @@ public:
static Q_CORE_EXPORT QString windowsString(int errorCode = -1); static Q_CORE_EXPORT QString windowsString(int errorCode = -1);
#endif #endif
//data members // data members
int errorCode = 0; int errorCode = 0;
ErrorScope errorScope = NoError; ErrorScope errorScope = NoError;
}; };

View File

@ -658,7 +658,7 @@ static QString find_translation(const QLocale & locale,
QString lang = languages.at(i); QString lang = languages.at(i);
QString lowerLang = lang.toLower(); QString lowerLang = lang.toLower();
if (lang != lowerLang) if (lang != lowerLang)
languages.insert(i+1, lowerLang); languages.insert(i + 1, lowerLang);
} }
#endif #endif
@ -837,7 +837,7 @@ bool QTranslatorPrivate::do_load(const uchar *data, qsizetype len, const QString
} }
if (tag == QTranslatorPrivate::Language) { if (tag == QTranslatorPrivate::Language) {
language = QString::fromUtf8((const char*)data, blockLen); language = QString::fromUtf8((const char *)data, blockLen);
} else if (tag == QTranslatorPrivate::Contexts) { } else if (tag == QTranslatorPrivate::Contexts) {
contextArray = data; contextArray = data;
contextLength = blockLen; contextLength = blockLen;
@ -906,7 +906,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
uchar tag = 0; uchar tag = 0;
if (m < end) if (m < end)
tag = read8(m++); tag = read8(m++);
switch((Tag)tag) { switch ((Tag)tag) {
case Tag_End: case Tag_End:
goto end; goto end;
case Tag_Translation: { case Tag_Translation: {
@ -1015,7 +1015,7 @@ QString QTranslatorPrivate::do_translate(const char *context, const char *source
elfHash_finish(h); elfHash_finish(h);
const uchar *start = offsetArray; const uchar *start = offsetArray;
const uchar *end = start + ((numItems-1) << 3); const uchar *end = start + ((numItems - 1) << 3);
while (start <= end) { while (start <= end) {
const uchar *middle = start + (((end - start) >> 4) << 3); const uchar *middle = start + (((end - start) >> 4) << 3);
uint hash = read32(middle); uint hash = read32(middle);
@ -1031,7 +1031,7 @@ QString QTranslatorPrivate::do_translate(const char *context, const char *source
if (start <= end) { if (start <= end) {
// go back on equal key // go back on equal key
while (start != offsetArray && read32(start) == read32(start-8)) while (start != offsetArray && read32(start) == read32(start - 8))
start -= 8; start -= 8;
while (start < offsetArray + offsetLength) { while (start < offsetArray + offsetLength) {

View File

@ -979,7 +979,7 @@ QMetaType QVariant::metaType() const
/*! /*!
Assigns the value of the variant \a variant to this variant. Assigns the value of the variant \a variant to this variant.
*/ */
QVariant& QVariant::operator=(const QVariant &variant) QVariant &QVariant::operator=(const QVariant &variant)
{ {
if (this == &variant) if (this == &variant)
return *this; return *this;
@ -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
@ -1273,7 +1272,7 @@ void QVariant::save(QDataStream &s) const
typeId = 75; typeId = 75;
} else if (typeId >= Qt5KeySequence && typeId <= Qt5QQuaternion) { } else if (typeId >= Qt5KeySequence && typeId <= Qt5QQuaternion) {
// and as a result these types received lower ids too // and as a result these types received lower ids too
typeId +=1; typeId += 1;
} else if (typeId > Qt5QQuaternion || typeId == QMetaType::QUuid) { } else if (typeId > Qt5QQuaternion || typeId == QMetaType::QUuid) {
// These existed in Qt 4 only as a custom type // These existed in Qt 4 only as a custom type
typeId = 127; typeId = 127;
@ -1309,7 +1308,7 @@ void QVariant::save(QDataStream &s) const
\sa{Serializing Qt Data Types}{Format of the QDataStream operators} \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/ */
QDataStream& operator>>(QDataStream &s, QVariant &p) QDataStream &operator>>(QDataStream &s, QVariant &p)
{ {
p.load(s); p.load(s);
return s; return s;
@ -1320,7 +1319,7 @@ QDataStream& operator>>(QDataStream &s, QVariant &p)
\sa{Serializing Qt Data Types}{Format of the QDataStream operators} \sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/ */
QDataStream& operator<<(QDataStream &s, const QVariant &p) QDataStream &operator<<(QDataStream &s, const QVariant &p)
{ {
p.save(s); p.save(s);
return s; return s;
@ -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,19 +2388,16 @@ 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
*/ */
void* QVariant::data() void *QVariant::data()
{ {
detach(); detach();
// set is_null to false, as the caller is likely to write some data into this variant // set is_null to false, as the caller is likely to write some data into this variant
@ -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.

View File

@ -203,8 +203,8 @@ class Q_CORE_EXPORT QVariant
QVariant(QTime time); QVariant(QTime time);
QVariant(const QDateTime &datetime); QVariant(const QDateTime &datetime);
QVariant(const QList<QVariant> &list); QVariant(const QList<QVariant> &list);
QVariant(const QMap<QString,QVariant> &map); QVariant(const QMap<QString, QVariant> &map);
QVariant(const QHash<QString,QVariant> &hash); QVariant(const QHash<QString, QVariant> &hash);
#ifndef QT_NO_GEOM_VARIANT #ifndef QT_NO_GEOM_VARIANT
QVariant(const QSize &size); QVariant(const QSize &size);
QVariant(const QSizeF &size); QVariant(const QSizeF &size);
@ -414,7 +414,7 @@ class Q_CORE_EXPORT QVariant
bool canView() const bool canView() const
{ return canView(QMetaType::fromType<T>()); } { return canView(QMetaType::fromType<T>()); }
public: public:
struct PrivateShared struct PrivateShared
{ {
private: private:
@ -579,14 +579,14 @@ inline bool QVariant::isValid() const
} }
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream& operator>> (QDataStream& s, QVariant& p); Q_CORE_EXPORT QDataStream &operator>>(QDataStream &s, QVariant &p);
Q_CORE_EXPORT QDataStream& operator<< (QDataStream& s, const QVariant& p); Q_CORE_EXPORT QDataStream &operator<<(QDataStream &s, const QVariant &p);
#if QT_DEPRECATED_SINCE(6, 0) #if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED QT_WARNING_DISABLE_DEPRECATED
QT_DEPRECATED_VERSION_6_0 QT_DEPRECATED_VERSION_6_0
inline QDataStream& operator>> (QDataStream& s, QVariant::Type &p) inline QDataStream &operator>>(QDataStream &s, QVariant::Type &p)
{ {
quint32 u; quint32 u;
s >> u; s >> u;
@ -594,7 +594,7 @@ inline QDataStream& operator>> (QDataStream& s, QVariant::Type &p)
return s; return s;
} }
QT_DEPRECATED_VERSION_6_0 QT_DEPRECATED_VERSION_6_0
inline QDataStream& operator<< (QDataStream& s, const QVariant::Type p) inline QDataStream &operator<<(QDataStream &s, const QVariant::Type p)
{ {
s << static_cast<quint32>(p); s << static_cast<quint32>(p);
return s; return s;