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

@ -68,11 +68,11 @@ enum {
Offset4 = 0x00010000,
Offset5 = 0x00100000,
Size0 = Offset1 - Offset0,
Size1 = Offset2 - Offset1,
Size2 = Offset3 - Offset2,
Size3 = Offset4 - Offset3,
Size4 = Offset5 - Offset4,
Size0 = Offset1 - Offset0,
Size1 = Offset2 - Offset1,
Size2 = Offset3 - Offset2,
Size3 = Offset4 - Offset3,
Size4 = Offset5 - Offset4,
Size5 = QtTimerIdFreeListConstants::MaxIndex - Offset5
};

View File

@ -262,19 +262,22 @@ public:
Q_DISABLE_COPY(QAppleLogActivity)
QAppleLogActivity(QAppleLogActivity&& other)
: activity(qExchange(other.activity, nullptr)), state(other.state) {}
QAppleLogActivity(QAppleLogActivity &&other)
: activity(qExchange(other.activity, nullptr)), state(other.state)
{
}
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QAppleLogActivity)
QAppleLogActivity&& enter()
QAppleLogActivity &&enter()
{
if (activity)
os_activity_scope_enter(static_cast<os_activity_t>(*this), &state);
return std::move(*this);
}
void leave() {
void leave()
{
if (activity)
os_activity_scope_leave(&state);
}
@ -333,10 +336,13 @@ public:
}
#endif
QMacNotificationObserver(const QMacNotificationObserver& other) = delete;
QMacNotificationObserver(QMacNotificationObserver&& other) : observer(qExchange(other.observer, nullptr)) {}
QMacNotificationObserver(const QMacNotificationObserver &other) = delete;
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)
void swap(QMacNotificationObserver &other) noexcept
@ -378,7 +384,8 @@ public:
~QMacKeyValueObserver() { removeObserver(); }
QMacKeyValueObserver &operator=(const QMacKeyValueObserver &other) {
QMacKeyValueObserver &operator=(const QMacKeyValueObserver &other)
{
QMacKeyValueObserver tmp(other);
swap(tmp);
return *this;

View File

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

View File

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

View File

@ -347,9 +347,10 @@ private:
class Q_CORE_EXPORT QTimerEvent : public QEvent
{
public:
explicit QTimerEvent( int timerId );
explicit QTimerEvent(int timerId);
~QTimerEvent();
int timerId() const { return id; }
protected:
int id;
};
@ -359,12 +360,13 @@ class QObject;
class Q_CORE_EXPORT QChildEvent : public QEvent
{
public:
QChildEvent( Type type, QObject *child );
QChildEvent(Type type, QObject *child);
~QChildEvent();
QObject *child() const { return c; }
bool added() const { return type() == ChildAdded; }
bool polished() const { return type() == ChildPolished; }
bool removed() const { return type() == ChildRemoved; }
protected:
QObject *c;
};
@ -387,6 +389,7 @@ public:
explicit QDeferredDeleteEvent();
~QDeferredDeleteEvent();
int loopLevel() const { return level; }
private:
int level;
friend class QCoreApplication;

View File

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

View File

@ -212,7 +212,6 @@ QT_BEGIN_NAMESPACE
\sa isValid(), start()
*/
/*!
\fn bool QElapsedTimer::operator ==(const QElapsedTimer &other) const
@ -238,7 +237,7 @@ static const qint64 invalidData = Q_INT64_C(0x8000000000000000);
*/
void QElapsedTimer::invalidate() noexcept
{
t1 = t2 = invalidData;
t1 = t2 = invalidData;
}
/*!

View File

@ -68,7 +68,7 @@ bool QElapsedTimer::isMonotonic() noexcept
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)
{
if (info.denom == 0)

View File

@ -131,7 +131,7 @@ static void initThreadPipeFD(int fd)
bool QThreadPipe::init()
{
#if defined(Q_OS_WASM)
// do nothing.
// do nothing.
#elif defined(Q_OS_VXWORKS)
qsnprintf(name, sizeof(name), "/pipe/qt_%08x", int(taskIdSelf()));

View File

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

View File

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

View File

@ -43,7 +43,6 @@
static const char logTag[] = "QtCore";
Q_CORE_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
{
Q_UNUSED(reserved);
@ -63,16 +62,14 @@ Q_CORE_EXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
_JNIEnv uenv;
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");
return JNI_ERR;
}
JNIEnv *env = uenv.nenv;
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");
return ret;
}

View File

@ -229,7 +229,7 @@ inline qreal qFastCos(qreal x)
constexpr inline float qDegreesToRadians(float degrees)
{
return degrees * float(M_PI/180);
return degrees * float(M_PI / 180);
}
constexpr inline double qDegreesToRadians(double degrees)
@ -250,7 +250,7 @@ constexpr inline double qDegreesToRadians(T degrees)
constexpr inline float qRadiansToDegrees(float radians)
{
return radians * float(180/M_PI);
return radians * float(180 / M_PI);
}
constexpr inline double qRadiansToDegrees(double radians)
@ -268,7 +268,8 @@ constexpr inline long double qRadiansToDegrees(long double radians)
// using integral datatypes...
namespace QtPrivate {
constexpr inline quint32 qConstexprNextPowerOfTwo(quint32 v) {
constexpr inline quint32 qConstexprNextPowerOfTwo(quint32 v)
{
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
@ -278,7 +279,8 @@ constexpr inline quint32 qConstexprNextPowerOfTwo(quint32 v) {
return v;
}
constexpr inline quint64 qConstexprNextPowerOfTwo(quint64 v) {
constexpr inline quint64 qConstexprNextPowerOfTwo(quint64 v)
{
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;

View File

@ -2661,12 +2661,11 @@ int QMetaEnum::value(int index) const
{
if (!mobj)
return 0;
if (index >= 0 && index < int(data.keyCount()))
return mobj->d.data[data.data() + 2*index + 1];
if (index >= 0 && index < int(data.keyCount()))
return mobj->d.data[data.data() + 2 * index + 1];
return -1;
}
/*!
Returns \c true if this enumerator is used as a flag; otherwise returns
false.
@ -2731,7 +2730,7 @@ int QMetaEnum::keyToValue(const char *key, bool *ok) const
const char *s = key + qstrlen(key);
while (s > key && *s != ':')
--s;
if (s > key && *(s-1)==':') {
if (s > key && *(s - 1) == ':') {
scope = s - key - 1;
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) {
if (ok != nullptr)
*ok = true;
return mobj->d.data[data.data() + 2*i + 1];
return mobj->d.data[data.data() + 2 * i + 1];
}
}
return -1;
@ -2755,13 +2754,13 @@ int QMetaEnum::keyToValue(const char *key, bool *ok) const
\sa isFlag(), valueToKeys()
*/
const char* QMetaEnum::valueToKey(int value) const
const char *QMetaEnum::valueToKey(int value) const
{
if (!mobj)
return nullptr;
for (int i = 0; i < int(data.keyCount()); ++i)
if (value == (int)mobj->d.data[data.data() + 2*i + 1])
return rawStringData(mobj, mobj->d.data[data.data() + 2*i]);
if (value == (int)mobj->d.data[data.data() + 2 * i + 1])
return rawStringData(mobj, mobj->d.data[data.data() + 2 * i]);
return nullptr;
}
@ -2797,7 +2796,7 @@ int QMetaEnum::keysToValue(const char *keys, bool *ok) const
const char *s = key + qstrlen(key);
while (s > key && *s != ':')
--s;
if (s > key && *(s-1)==':') {
if (s > key && *(s - 1) == ':') {
scope = s - key - 1;
key += scope + 2;
}
@ -2833,12 +2832,12 @@ QByteArray QMetaEnum::valueToKeys(int value) const
int v = value;
// reverse iterate to ensure values like Qt::Dialog=0x2|Qt::Window are processed first.
for (int i = data.keyCount() - 1; i >= 0; --i) {
int k = mobj->d.data[data.data() + 2*i + 1];
if ((k != 0 && (v & k) == k ) || (k == value)) {
int k = mobj->d.data[data.data() + 2 * i + 1];
if ((k != 0 && (v & k) == k) || (k == value)) {
v = v & ~k;
if (!keys.isEmpty())
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;
@ -2861,7 +2860,6 @@ QMetaEnum::QMetaEnum(const QMetaObject *mobj, int index)
The enum needs to be declared with Q_ENUM.
*/
/*!
\class QMetaProperty
\inmodule QtCore
@ -2977,7 +2975,7 @@ QMetaType QMetaProperty::metaType() 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, ':');
// ':' will always appear in pairs
Q_ASSERT(colon <= enum_name || *(colon-1) == ':');
Q_ASSERT(colon <= enum_name || *(colon - 1) == ':');
if (colon > enum_name) {
int len = colon-enum_name-1;
scope_buffer = (char *)malloc(len+1);
int len = colon - enum_name - 1;
scope_buffer = (char *)malloc(len + 1);
memcpy(scope_buffer, enum_name, len);
scope_buffer[len] = '\0';
scope_name = scope_buffer;
enum_name = colon+1;
enum_name = colon + 1;
}
const QMetaObject *scope = nullptr;
@ -3416,7 +3414,6 @@ bool QMetaProperty::isWritable() const
return data.flags() & Writable;
}
/*!
Returns \c false if the \c{Q_PROPERTY()}'s \c DESIGNABLE attribute
is false; otherwise returns \c true.
@ -3554,7 +3551,6 @@ bool QMetaProperty::isBindable() const
\sa QMetaObject
*/
/*!
\fn QMetaClassInfo::QMetaClassInfo()
\internal
@ -3582,7 +3578,7 @@ const char *QMetaClassInfo::name() const
\sa name()
*/
const char* QMetaClassInfo::value() const
const char *QMetaClassInfo::value() const
{
if (!mobj)
return nullptr;
@ -3603,7 +3599,6 @@ const char* QMetaClassInfo::value() const
our state machine and dbus.
*/
/*!
\macro QGenericArgument Q_ARG(Type, const Type &value)
\relates QMetaObject

View File

@ -175,7 +175,7 @@ public:
{
typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SignalType;
static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
"No Q_OBJECT in the class with the signal");
"No Q_OBJECT in the class with the signal");
return fromSignalImpl(&SignalType::Object::staticMetaObject,
reinterpret_cast<void **>(&signal));
}
@ -235,18 +235,20 @@ public:
const char *scope() const;
int keyToValue(const char *key, bool *ok = nullptr) const;
const char* valueToKey(int value) const;
int keysToValue(const char * keys, bool *ok = nullptr) const;
const char *valueToKey(int value) const;
int keysToValue(const char *keys, bool *ok = nullptr) const;
QByteArray valueToKeys(int value) const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
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,
"QMetaEnum::fromType only works with enums declared as "
"Q_ENUM, Q_ENUM_NS, Q_FLAG or Q_FLAG_NS");
"QMetaEnum::fromType only works with enums declared as "
"Q_ENUM, Q_ENUM_NS, Q_FLAG or Q_FLAG_NS");
const QMetaObject *metaObject = qt_getEnumMetaObject(T());
const char *name = qt_getEnumName(T());
return metaObject->enumerator(metaObject->indexOfEnumerator(name));
@ -363,6 +365,7 @@ public:
const char *name() const;
const char *value() const;
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
private:
struct Data {
enum { Size = 2 };

View File

@ -65,14 +65,14 @@ QT_BEGIN_NAMESPACE
// ### TODO Qt6: add a proper namespace with Q_NAMESPACE and use scoped enums
// A namespace and scoped are needed to avoid enum clashes
enum PropertyFlags {
enum PropertyFlags {
Invalid = 0x00000000,
Readable = 0x00000001,
Writable = 0x00000002,
Resettable = 0x00000004,
EnumOrFlag = 0x00000008,
Alias = 0x00000010,
//Reserved for future usage = 0x00000020,
// Reserved for future usage = 0x00000020,
StdCppSet = 0x00000100,
Constant = 0x00000400,
Final = 0x00000800,
@ -84,11 +84,11 @@ enum PropertyFlags {
Bindable = 0x02000000
};
enum MethodFlags {
enum MethodFlags {
AccessPrivate = 0x00,
AccessProtected = 0x01,
AccessPublic = 0x02,
AccessMask = 0x03, //mask
AccessMask = 0x03, // mask
MethodMethod = 0x00,
MethodSignal = 0x04,
@ -174,7 +174,7 @@ struct QMetaObjectPrivate
// 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
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 { IntsPerProperty = QMetaProperty::Data::Size };
@ -210,11 +210,12 @@ struct QMetaObjectPrivate
static int indexOfConstructor(const QMetaObject *m, const QByteArray &name,
int argc, const QArgumentType *types);
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);
int offset = 0;
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;
}
Q_CORE_EXPORT static int absoluteSignalCount(const QMetaObject *m);
@ -227,7 +228,7 @@ struct QMetaObjectPrivate
static QList<QByteArray> parameterTypeNamesFromSignature(const char *signature);
#ifndef QT_NO_QOBJECT
//defined in qobject.cpp
// defined in qobject.cpp
enum DisconnectType { DisconnectAll, DisconnectOne };
static void memberIndexes(const QObject *obj, const QMetaMethod &member,
int *signalIndex, int *methodIndex);

View File

@ -186,7 +186,7 @@ Q_DECLARE_TYPEINFO(QMetaPropertyBuilderPrivate, Q_MOVABLE_TYPE);
class QMetaEnumBuilderPrivate
{
public:
QMetaEnumBuilderPrivate(const QByteArray& _name)
QMetaEnumBuilderPrivate(const QByteArray &_name)
: name(_name), enumName(_name), isFlag(false), isScoped(false)
{
}
@ -253,8 +253,8 @@ QMetaObjectBuilder::QMetaObjectBuilder()
\sa addMetaObject()
*/
QMetaObjectBuilder::QMetaObjectBuilder
(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members)
QMetaObjectBuilder::QMetaObjectBuilder(const QMetaObject *prototype,
QMetaObjectBuilder::AddMembers members)
{
d = new QMetaObjectBuilderPrivate();
addMetaObject(prototype, members);
@ -285,7 +285,7 @@ QByteArray QMetaObjectBuilder::className() const
\sa className(), setSuperClass()
*/
void QMetaObjectBuilder::setClassName(const QByteArray& name)
void QMetaObjectBuilder::setClassName(const QByteArray &name)
{
d->className = name;
}
@ -418,7 +418,7 @@ int QMetaObjectBuilder::relatedMetaObjectCount() const
\sa method(), methodCount(), removeMethod(), indexOfMethod()
*/
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray &signature)
{
int index = int(d->methods.size());
d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
@ -434,12 +434,11 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
\sa method(), methodCount(), removeMethod(), indexOfMethod()
*/
QMetaMethodBuilder QMetaObjectBuilder::addMethod
(const QByteArray& signature, const QByteArray& returnType)
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray &signature,
const QByteArray &returnType)
{
int index = int(d->methods.size());
d->methods.push_back(QMetaMethodBuilderPrivate
(QMetaMethod::Method, signature, returnType));
d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature, returnType));
return QMetaMethodBuilder(this, index);
}
@ -454,7 +453,7 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod
\sa method(), methodCount(), removeMethod(), indexOfMethod()
*/
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype)
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod &prototype)
{
QMetaMethodBuilder method;
if (prototype.methodType() == QMetaMethod::Method)
@ -482,7 +481,7 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype)
\sa addMethod(), addSignal(), indexOfSlot()
*/
QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray &signature)
{
int index = int(d->methods.size());
d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
@ -497,11 +496,11 @@ QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
\sa addMethod(), addSlot(), indexOfSignal()
*/
QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray &signature)
{
int index = int(d->methods.size());
d->methods.push_back(QMetaMethodBuilderPrivate
(QMetaMethod::Signal, signature, QByteArray("void"), QMetaMethod::Public));
d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Signal, signature,
QByteArray("void"), QMetaMethod::Public));
return QMetaMethodBuilder(this, index);
}
@ -514,7 +513,7 @@ QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
\sa constructor(), constructorCount(), removeConstructor()
\sa indexOfConstructor()
*/
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature)
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray &signature)
{
int index = int(d->constructors.size());
d->constructors.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature,
@ -533,7 +532,7 @@ QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signatur
\sa constructor(), constructorCount(), removeConstructor()
\sa indexOfConstructor()
*/
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototype)
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod &prototype)
{
Q_ASSERT(prototype.methodType() == QMetaMethod::Constructor);
QMetaMethodBuilder ctor = addConstructor(prototype.methodSignature());
@ -554,8 +553,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototy
\sa property(), propertyCount(), removeProperty(), indexOfProperty()
*/
QMetaPropertyBuilder QMetaObjectBuilder::addProperty
(const QByteArray& name, const QByteArray& type, int notifierId)
QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QByteArray &name, const QByteArray &type,
int notifierId)
{
int index = int(d->properties.size());
d->properties.push_back(QMetaPropertyBuilderPrivate(name, type, notifierId));
@ -570,7 +569,7 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty
\sa property(), propertyCount(), removeProperty(), indexOfProperty()
*/
QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& prototype)
QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty &prototype)
{
QMetaPropertyBuilder property = addProperty(prototype.name(), prototype.typeName());
property.setReadable(prototype.isReadable());
@ -604,7 +603,7 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot
\sa enumerator(), enumeratorCount(), removeEnumerator()
\sa indexOfEnumerator()
*/
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray &name)
{
int index = int(d->enumerators.size());
d->enumerators.push_back(QMetaEnumBuilderPrivate(name));
@ -620,7 +619,7 @@ QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
\sa enumerator(), enumeratorCount(), removeEnumerator()
\sa indexOfEnumerator()
*/
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum& prototype)
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum &prototype)
{
QMetaEnumBuilder en = addEnumerator(prototype.name());
en.setEnumName(prototype.enumName());
@ -639,7 +638,7 @@ QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QMetaEnum& prototype)
\sa classInfoCount(), classInfoName(), classInfoValue(), removeClassInfo()
\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();
d->classInfoNames += name;
@ -673,8 +672,8 @@ int QMetaObjectBuilder::addRelatedMetaObject(const QMetaObject *meta)
The \a members parameter indicates which members of \a prototype
should be added. The default is AllMembers.
*/
void QMetaObjectBuilder::addMetaObject
(const QMetaObject *prototype, QMetaObjectBuilder::AddMembers members)
void QMetaObjectBuilder::addMetaObject(const QMetaObject *prototype,
QMetaObjectBuilder::AddMembers members)
{
Q_ASSERT(prototype);
int index;
@ -948,7 +947,7 @@ void QMetaObjectBuilder::removeRelatedMetaObject(int index)
\sa method(), methodCount(), addMethod(), removeMethod()
*/
int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
int QMetaObjectBuilder::indexOfMethod(const QByteArray &signature)
{
QByteArray sig = QMetaObject::normalizedSignature(signature);
for (const auto &method : d->methods) {
@ -964,7 +963,7 @@ int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
\sa indexOfMethod(), indexOfSlot()
*/
int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
int QMetaObjectBuilder::indexOfSignal(const QByteArray &signature)
{
QByteArray sig = QMetaObject::normalizedSignature(signature);
for (const auto &method : d->methods) {
@ -980,7 +979,7 @@ int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
\sa indexOfMethod(), indexOfSignal()
*/
int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
int QMetaObjectBuilder::indexOfSlot(const QByteArray &signature)
{
QByteArray sig = QMetaObject::normalizedSignature(signature);
for (const auto &method : d->methods) {
@ -996,7 +995,7 @@ int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
\sa constructor(), constructorCount(), addConstructor(), removeConstructor()
*/
int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
int QMetaObjectBuilder::indexOfConstructor(const QByteArray &signature)
{
QByteArray sig = QMetaObject::normalizedSignature(signature);
for (const auto &constructor : d->constructors) {
@ -1012,7 +1011,7 @@ int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
\sa property(), propertyCount(), addProperty(), removeProperty()
*/
int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
int QMetaObjectBuilder::indexOfProperty(const QByteArray &name)
{
for (const auto &property : d->properties) {
if (name == property.name)
@ -1027,7 +1026,7 @@ int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
\sa enumertor(), enumeratorCount(), addEnumerator(), removeEnumerator()
*/
int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name)
int QMetaObjectBuilder::indexOfEnumerator(const QByteArray &name)
{
for (const auto &enumerator : d->enumerators) {
if (name == enumerator.name)
@ -1043,7 +1042,7 @@ int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name)
\sa classInfoName(), classInfoValue(), classInfoCount(), addClassInfo()
\sa removeClassInfo()
*/
int QMetaObjectBuilder::indexOfClassInfo(const QByteArray& name)
int QMetaObjectBuilder::indexOfClassInfo(const QByteArray &name)
{
for (int index = 0; index < d->classInfoNames.size(); ++index) {
if (name == d->classInfoNames[index])
@ -1107,7 +1106,7 @@ static void writeString(char *out, int i, const QByteArray &str,
int offset = offsetOfStringdataMember + stringdataOffset;
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);
out[offsetOfStringdataMember + stringdataOffset + size] = '\0';
@ -1121,13 +1120,13 @@ static void writeString(char *out, int i, const QByteArray &str,
// moc (see generator.cpp).
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 stringdataOffset = 0;
// 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();
it != end; ++it) {
@ -1452,8 +1451,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
types++;
}
}
for (const auto &constructor: d->constructors) {
for (const auto &parameterType: constructor.parameterTypes()) {
for (const auto &constructor : d->constructors) {
for (const auto &parameterType : constructor.parameterTypes()) {
QMetaType mt = QMetaType::fromName(parameterType);
*types = reinterpret_cast<QtPrivate::QMetaTypeInterface *&>(mt);
types++;
@ -1507,7 +1506,8 @@ QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
{
int size = buildMetaObject(d, nullptr, 0, true);
if (size == -1) {
if (ok) *ok = false;
if (ok)
*ok = false;
return QByteArray();
}
@ -1516,7 +1516,8 @@ QByteArray QMetaObjectBuilder::toRelocatableData(bool *ok) const
char *buf = data.data();
memset(buf, 0, size);
buildMetaObject(d, buf, size, true);
if (ok) *ok = true;
if (ok)
*ok = true;
return data;
}
@ -1586,7 +1587,7 @@ void QMetaObjectBuilder::setStaticMetacallFunction
\sa deserialize()
*/
void QMetaObjectBuilder::serialize(QDataStream& stream) const
void QMetaObjectBuilder::serialize(QDataStream &stream) const
{
int index;
@ -1662,9 +1663,8 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
}
// Resolve a class name using the name reference map.
static const QMetaObject *resolveClassName
(const QMap<QByteArray, const QMetaObject *>& references,
const QByteArray& name)
static const QMetaObject *resolveClassName(const QMap<QByteArray, const QMetaObject *> &references,
const QByteArray &name)
{
if (name == QByteArray("QObject"))
return &QObject::staticMetaObject;
@ -1930,7 +1930,7 @@ QByteArray QMetaMethodBuilder::returnType() const
\sa returnType(), parameterTypes(), signature()
*/
void QMetaMethodBuilder::setReturnType(const QByteArray& value)
void QMetaMethodBuilder::setReturnType(const QByteArray &value)
{
QMetaMethodBuilderPrivate *d = d_func();
if (d)
@ -1970,7 +1970,7 @@ QList<QByteArray> QMetaMethodBuilder::parameterNames() const
\sa parameterNames()
*/
void QMetaMethodBuilder::setParameterNames(const QList<QByteArray>& value)
void QMetaMethodBuilder::setParameterNames(const QList<QByteArray> &value)
{
QMetaMethodBuilderPrivate *d = d_func();
if (d)
@ -1996,7 +1996,7 @@ QByteArray QMetaMethodBuilder::tag() const
\sa setTag()
*/
void QMetaMethodBuilder::setTag(const QByteArray& value)
void QMetaMethodBuilder::setTag(const QByteArray &value)
{
QMetaMethodBuilderPrivate *d = d_func();
if (d)
@ -2070,7 +2070,6 @@ int QMetaMethodBuilder::revision() const
if (d)
return d->revision;
return 0;
}
/*!
@ -2177,7 +2176,7 @@ QMetaMethodBuilder QMetaPropertyBuilder::notifySignal() const
\sa hasNotifySignal(), notifySignal(), removeNotifySignal()
*/
void QMetaPropertyBuilder::setNotifySignal(const QMetaMethodBuilder& value)
void QMetaPropertyBuilder::setNotifySignal(const QMetaMethodBuilder &value)
{
QMetaPropertyBuilderPrivate *d = d_func();
if (d) {
@ -2557,7 +2556,6 @@ int QMetaPropertyBuilder::revision() const
if (d)
return d->revision;
return 0;
}
/*!
@ -2572,7 +2570,6 @@ void QMetaPropertyBuilder::setRevision(int revision)
d->revision = revision;
}
/*!
\class QMetaEnumBuilder
\inmodule QtCore
@ -2740,7 +2737,7 @@ int QMetaEnumBuilder::value(int index) const
\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();
if (d) {

View File

@ -1179,11 +1179,11 @@ struct QMetaTypeIdQObject<T*, QMetaType::PointerToQObject>
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
if (const int id = metatype_id.loadAcquire())
return id;
const char * const cName = T::staticMetaObject.className();
const char *const cName = T::staticMetaObject.className();
QByteArray typeName;
typeName.reserve(int(strlen(cName)) + 1);
typeName.append(cName).append('*');
const int newId = qRegisterNormalizedMetaType<T*>(typeName);
const int newId = qRegisterNormalizedMetaType<T *>(typeName);
metatype_id.storeRelease(newId);
return newId;
}
@ -1201,7 +1201,7 @@ struct QMetaTypeIdQObject<T, QMetaType::IsGadget>
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
if (const int id = metatype_id.loadAcquire())
return id;
const char * const cName = T::staticMetaObject.className();
const char *const cName = T::staticMetaObject.className();
const int newId = qRegisterNormalizedMetaType<T>(cName);
metatype_id.storeRelease(newId);
return newId;
@ -1220,11 +1220,11 @@ struct QMetaTypeIdQObject<T*, QMetaType::PointerToGadget>
static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0);
if (const int id = metatype_id.loadAcquire())
return id;
const char * const cName = T::staticMetaObject.className();
const char *const cName = T::staticMetaObject.className();
QByteArray typeName;
typeName.reserve(int(strlen(cName)) + 1);
typeName.append(cName).append('*');
const int newId = qRegisterNormalizedMetaType<T*>(typeName);
const int newId = qRegisterNormalizedMetaType<T *>(typeName);
metatype_id.storeRelease(newId);
return newId;
}
@ -1491,7 +1491,6 @@ Q_DECLARE_METATYPE_TEMPLATE_2ARG(std::pair)
#define Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER(TEMPLATENAME) \
Q_DECLARE_SMART_POINTER_METATYPE(TEMPLATENAME)
QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER)
QT_BEGIN_NAMESPACE
@ -1500,7 +1499,6 @@ QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
QT_FOR_EACH_STATIC_TYPE(Q_DECLARE_BUILTIN_METATYPE)
Q_DECLARE_METATYPE(QtMetaTypePrivate::QPairVariantInterfaceImpl)
@ -1753,7 +1751,7 @@ private:
{
last = x;
if (output)
*(output-1) = x;
*(output - 1) = x;
}
constexpr void appendStr(const char *x)
@ -2052,7 +2050,7 @@ constexpr auto typenameHelper()
} else {
t1Name = typenameHelper<T1>();
}
if constexpr (bool (QMetaTypeId2<T2>::IsBuiltIn) ) {
if constexpr (bool(QMetaTypeId2<T2>::IsBuiltIn)) {
t2Name = QMetaTypeId2<T2>::nameAsArray;
} else {
t2Name = typenameHelper<T2>();
@ -2064,7 +2062,7 @@ constexpr auto typenameHelper()
std::array<char, length + 1> result {};
constexpr auto prefix = "std::pair<";
int currentLength = 0;
for (; currentLength < int(sizeof("std::pair<")-1); ++currentLength)
for (; currentLength < int(sizeof("std::pair<") - 1); ++currentLength)
result[currentLength] = prefix[currentLength];
for (int i = 0; i < int(t1Len); ++currentLength, ++i)
result[currentLength] = t1Name[i];
@ -2187,50 +2185,52 @@ public:
static constexpr QMetaTypeInterface::DefaultCtrFn getDefaultCtr()
{
if constexpr (std::is_default_constructible_v<S>) {
return [](const QMetaTypeInterface *, void *addr) { new (addr) S(); };
} else {
return nullptr;
}
if constexpr (std::is_default_constructible_v<S>) {
return [](const QMetaTypeInterface *, void *addr) { new (addr) S(); };
} else {
return nullptr;
}
}
static constexpr QMetaTypeInterface::CopyCtrFn getCopyCtr()
{
if constexpr (std::is_copy_constructible_v<S>) {
return [](const QMetaTypeInterface *, void *addr, const void *other) {
new (addr) S(*reinterpret_cast<const S *>(other));
};
} else {
return nullptr;
}
if constexpr (std::is_copy_constructible_v<S>) {
return [](const QMetaTypeInterface *, void *addr, const void *other) {
new (addr) S(*reinterpret_cast<const S *>(other));
};
} else {
return nullptr;
}
}
static constexpr QMetaTypeInterface::MoveCtrFn getMoveCtr()
{
if constexpr (std::is_move_constructible_v<S>) {
return [](const QMetaTypeInterface *, void *addr, void *other) {
new (addr) S(std::move(*reinterpret_cast<S *>(other)));
};
} else {
return nullptr;
}
if constexpr (std::is_move_constructible_v<S>) {
return [](const QMetaTypeInterface *, void *addr, void *other) {
new (addr) S(std::move(*reinterpret_cast<S *>(other)));
};
} else {
return nullptr;
}
}
static constexpr QMetaTypeInterface::DtorFn getDtor()
{
if constexpr (std::is_destructible_v<S>)
return [](const QMetaTypeInterface *, void *addr) { reinterpret_cast<S *>(addr)->~S(); };
else
return nullptr;
if constexpr (std::is_destructible_v<S>)
return [](const QMetaTypeInterface *, void *addr) {
reinterpret_cast<S *>(addr)->~S();
};
else
return nullptr;
}
static constexpr QMetaTypeInterface::LegacyRegisterOp getLegacyRegister()
{
if constexpr (QMetaTypeId2<S>::Defined && !QMetaTypeId2<S>::IsBuiltIn) {
return []() { QMetaTypeId2<S>::qt_metatype_id(); };
} else {
return nullptr;
}
if constexpr (QMetaTypeId2<S>::Defined && !QMetaTypeId2<S>::IsBuiltIn) {
return []() { QMetaTypeId2<S>::qt_metatype_id(); };
} else {
return nullptr;
}
}
static constexpr const char *getName()
@ -2340,16 +2340,15 @@ constexpr const QMetaTypeInterface *qMetaTypeInterfaceForType()
}
namespace detail {
template <typename T, typename ODR_VIOLATION_PREVENTER>
struct is_complete_helper {
template <typename U>
static auto check(U*) -> std::integral_constant<bool, sizeof(U) != 0>;
template<typename T, typename ODR_VIOLATION_PREVENTER>
struct is_complete_helper
{
template<typename U>
static auto check(U *) -> std::integral_constant<bool, sizeof(U) != 0>;
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>
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 *qMetaTypeWidgetsHelper;
namespace QtMetaTypePrivate {
template<typename T>
struct TypeDefinition {
struct TypeDefinition
{
static const bool IsAvailable = true;
};

View File

@ -45,7 +45,6 @@
QT_BEGIN_NAMESPACE
class QUrl;
class QMimeDataPrivate;
@ -84,8 +83,10 @@ public:
virtual QStringList formats() const;
void clear();
protected:
virtual QVariant retrieveData(const QString &mimetype, QMetaType preferredType) const;
private:
Q_DISABLE_COPY(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();
int *typeIds = new int [parameterCount + 1];
int *typeIds = new int[parameterCount + 1];
Q_CHECK_PTR(typeIds);
for (int i = 0; i < parameterCount; ++i) {
const QMetaType metaType = method.parameterMetaType(i);
@ -109,10 +109,11 @@ static int *queuedConnectionTypes(const QMetaMethod& method)
typeIds[i] = metaType.id();
if (!typeIds[i]) {
const QByteArray typeName = method.parameterTypeName(i);
qCWarning(lcConnect, "QObject::connect: Cannot queue arguments of type '%s'\n"
"(Make sure '%s' is registered using qRegisterMetaType().)",
typeName.constData(), typeName.constData());
delete [] typeIds;
qCWarning(lcConnect,
"QObject::connect: Cannot queue arguments of type '%s'\n"
"(Make sure '%s' is registered using qRegisterMetaType().)",
typeName.constData(), typeName.constData());
delete[] typeIds;
return nullptr;
}
}
@ -123,7 +124,7 @@ static int *queuedConnectionTypes(const QMetaMethod& method)
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) {
const QArgumentType &type = argumentTypes[i];
if (type.type())
@ -134,9 +135,10 @@ static int *queuedConnectionTypes(const QArgumentType *argumentTypes, int argc)
types[i] = QMetaType::fromName(type.name()).id();
if (!types[i]) {
qCWarning(lcConnect, "QObject::connect: Cannot queue arguments of type '%s'\n"
"(Make sure '%s' is registered using qRegisterMetaType().)",
type.name().constData(), type.name().constData());
qCWarning(lcConnect,
"QObject::connect: Cannot queue arguments of type '%s'\n"
"(Make sure '%s' is registered using qRegisterMetaType().)",
type.name().constData(), type.name().constData());
return nullptr;
}
}
@ -227,7 +229,8 @@ QObjectPrivate::~QObjectPrivate()
thisThreadData->deref();
if (metaObject) metaObject->objectDestroyed(q_ptr);
if (metaObject)
metaObject->objectDestroyed(q_ptr);
delete extraData;
}
@ -595,7 +598,7 @@ QMetaCallEvent::~QMetaCallEvent()
if (t[i].isValid() && 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_);
}
if (d.slotObj_)
@ -1087,7 +1090,7 @@ QObjectPrivate::Connection::~Connection()
if (ownArgumentTypes) {
const int *v = argumentTypes.loadRelaxed();
if (v != &DIRECT_CONNECTION_ONLY)
delete [] v;
delete[] v;
}
if (isSlotObject)
slotObj->destroyIfLastRef();
@ -1277,13 +1280,13 @@ bool QObject::event(QEvent *e)
{
switch (e->type()) {
case QEvent::Timer:
timerEvent((QTimerEvent*)e);
timerEvent((QTimerEvent *)e);
break;
case QEvent::ChildAdded:
case QEvent::ChildPolished:
case QEvent::ChildRemoved:
childEvent((QChildEvent*)e);
childEvent((QChildEvent *)e);
break;
case QEvent::DeferredDelete:
@ -2101,7 +2104,7 @@ void QObjectPrivate::setParent_helper(QObject *o)
return;
}
parent->d_func()->children.append(q);
if(sendChildEvents && parent->d_func()->receiveChildEvents) {
if (sendChildEvents && parent->d_func()->receiveChildEvents) {
if (!isWidget) {
QChildEvent e(QEvent::ChildAdded, q);
QCoreApplication::sendEvent(parent, &e);
@ -2168,7 +2171,7 @@ void QObject::installEventFilter(QObject *obj)
d->extraData = new QObjectPrivate::ExtraData;
// 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.prepend(obj);
}
@ -2197,7 +2200,6 @@ void QObject::removeEventFilter(QObject *obj)
}
}
/*!
\fn void QObject::destroyed(QObject *obj)
@ -2284,7 +2286,6 @@ void QObject::deleteLater()
Signals and slots
*****************************************************************************/
const char *qFlagLocation(const char *method)
{
QThreadData *currentThreadData = QThreadData::current(false);
@ -2299,7 +2300,7 @@ static int extract_code(const char *member)
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)) {
// 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);
if (sigcode != QSIGNAL_CODE) {
if (sigcode == QSLOT_CODE)
qCWarning(lcConnect, "QObject::%s: Attempt to %s non-signal %s::%s",
func, op, sender->metaObject()->className(), signal+1);
qCWarning(lcConnect, "QObject::%s: Attempt to %s non-signal %s::%s", func, op,
sender->metaObject()->className(), signal + 1);
else
qCWarning(lcConnect, "QObject::%s: Use the SIGNAL macro to %s %s::%s",
func, op, sender->metaObject()->className(), signal);
qCWarning(lcConnect, "QObject::%s: Use the SIGNAL macro to %s %s::%s", func, op,
sender->metaObject()->className(), signal);
return false;
}
return true;
}
static bool check_method_code(int code, const QObject *object,
const char *method, const char *func)
static bool check_method_code(int code, const QObject *object, const char *method, const char *func)
{
if (code != QSLOT_CODE && code != QSIGNAL_CODE) {
qCWarning(lcConnect, "QObject::%s: Use the SLOT or SIGNAL macro to "
"%s %s::%s", func, func, object->metaObject()->className(), method);
qCWarning(lcConnect,
"QObject::%s: Use the SLOT or SIGNAL macro to "
"%s %s::%s",
func, func, object->metaObject()->className(), method);
return false;
}
return true;
@ -2346,21 +2348,15 @@ static void err_method_notfound(const QObject *object,
case QSIGNAL_CODE: type = "signal"; break;
}
const char *loc = extract_location(method);
if (strchr(method,')') == nullptr) // common typing mistake
qCWarning(lcConnect, "QObject::%s: Parentheses expected, %s %s::%s%s%s",
func, type, object->metaObject()->className(), method+1,
loc ? " in ": "", loc ? loc : "");
if (strchr(method, ')') == nullptr) // common typing mistake
qCWarning(lcConnect, "QObject::%s: Parentheses expected, %s %s::%s%s%s", func, type,
object->metaObject()->className(), method + 1, loc ? " in " : "", loc ? loc : "");
else
qCWarning(lcConnect, "QObject::%s: No such %s %s::%s%s%s",
func, type, object->metaObject()->className(), method+1,
loc ? " in ": "", loc ? loc : "");
qCWarning(lcConnect, "QObject::%s: No such %s %s::%s%s%s", func, type,
object->metaObject()->className(), method + 1, 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 b = receiver ? receiver->objectName() : QString();
@ -2489,7 +2485,7 @@ int QObject::receivers(const char *signal) const
int signal_index = d->signalIndex(signal);
if (signal_index < 0) {
#ifndef QT_NO_DEBUG
err_method_notfound(this, signal-1, "receivers");
err_method_notfound(this, signal - 1, "receivers");
#endif
return 0;
}
@ -2611,12 +2607,12 @@ static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaM
if (signal.attributes() & QMetaMethod::Compatibility) {
if (!(method.attributes() & QMetaMethod::Compatibility))
qCWarning(lcConnect, "QObject::connect: Connecting from COMPAT signal (%s::%s)",
sender->className(), signal.methodSignature().constData());
} else if ((method.attributes() & QMetaMethod::Compatibility) &&
method.methodType() == QMetaMethod::Signal) {
sender->className(), signal.methodSignature().constData());
} else if ((method.attributes() & QMetaMethod::Compatibility)
&& method.methodType() == QMetaMethod::Signal) {
qCWarning(lcConnect, "QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)",
sender->className(), signal.methodSignature().constData(),
receiver->className(), method.methodSignature().constData());
sender->className(), signal.methodSignature().constData(), receiver->className(),
method.methodSignature().constData());
}
}
#endif
@ -2693,15 +2689,15 @@ static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaM
{Differences between String-Based and Functor-Based Connections}
*/
QMetaObject::Connection QObject::connect(const QObject *sender, const char *signal,
const QObject *receiver, const char *method,
Qt::ConnectionType type)
const QObject *receiver, const char *method,
Qt::ConnectionType type)
{
if (sender == nullptr || receiver == nullptr || signal == nullptr || method == nullptr) {
qCWarning(lcConnect, "QObject::connect: Cannot connect %s::%s to %s::%s",
sender ? sender->metaObject()->className() : "(nullptr)",
(signal && *signal) ? signal+1 : "(nullptr)",
receiver ? receiver->metaObject()->className() : "(nullptr)",
(method && *method) ? method+1 : "(nullptr)");
sender ? sender->metaObject()->className() : "(nullptr)",
(signal && *signal) ? signal + 1 : "(nullptr)",
receiver ? receiver->metaObject()->className() : "(nullptr)",
(method && *method) ? method + 1 : "(nullptr)");
return QMetaObject::Connection(nullptr);
}
QByteArray tmp_signal_name;
@ -2710,7 +2706,7 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const char *sign
return QMetaObject::Connection(nullptr);
const QMetaObject *smeta = sender->metaObject();
const char *signal_arg = signal;
++signal; //skip code
++signal; // skip code
QArgumentTypeArray signalTypes;
Q_ASSERT(QMetaObjectPrivate::get(smeta)->revision >= 7);
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(),
methodTypes.size(), methodTypes.constData())) {
qCWarning(lcConnect, "QObject::connect: Incompatible sender/receiver arguments"
"\n %s::%s --> %s::%s",
sender->metaObject()->className(), signal,
receiver->metaObject()->className(), method);
qCWarning(lcConnect,
"QObject::connect: Incompatible sender/receiver arguments"
"\n %s::%s --> %s::%s",
sender->metaObject()->className(), signal, receiver->metaObject()->className(),
method);
return QMetaObject::Connection(nullptr);
}
@ -2839,10 +2836,10 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
|| signal.methodType() != QMetaMethod::Signal
|| method.methodType() == QMetaMethod::Constructor) {
qCWarning(lcConnect, "QObject::connect: Cannot connect %s::%s to %s::%s",
sender ? sender->metaObject()->className() : "(nullptr)",
signal.methodSignature().constData(),
receiver ? receiver->metaObject()->className() : "(nullptr)",
method.methodSignature().constData() );
sender ? sender->metaObject()->className() : "(nullptr)",
signal.methodSignature().constData(),
receiver ? receiver->metaObject()->className() : "(nullptr)",
method.methodSignature().constData());
return QMetaObject::Connection(nullptr);
}
@ -2858,26 +2855,27 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho
const QMetaObject *rmeta = receiver->metaObject();
if (signal_index == -1) {
qCWarning(lcConnect, "QObject::connect: Can't find signal %s on instance of class %s",
signal.methodSignature().constData(), smeta->className());
signal.methodSignature().constData(), smeta->className());
return QMetaObject::Connection(nullptr);
}
if (method_index == -1) {
qCWarning(lcConnect, "QObject::connect: Can't find method %s on instance of class %s",
method.methodSignature().constData(), rmeta->className());
method.methodSignature().constData(), rmeta->className());
return QMetaObject::Connection(nullptr);
}
if (!QMetaObject::checkConnectArgs(signal.methodSignature().constData(), method.methodSignature().constData())) {
qCWarning(lcConnect, "QObject::connect: Incompatible sender/receiver arguments"
"\n %s::%s --> %s::%s",
smeta->className(), signal.methodSignature().constData(),
rmeta->className(), method.methodSignature().constData());
if (!QMetaObject::checkConnectArgs(signal.methodSignature().constData(),
method.methodSignature().constData())) {
qCWarning(lcConnect,
"QObject::connect: Incompatible sender/receiver arguments"
"\n %s::%s --> %s::%s",
smeta->className(), signal.methodSignature().constData(), rmeta->className(),
method.methodSignature().constData());
return QMetaObject::Connection(nullptr);
}
int *types = nullptr;
if ((type == Qt::QueuedConnection)
&& !(types = queuedConnectionTypes(signal)))
if ((type == Qt::QueuedConnection) && !(types = queuedConnectionTypes(signal)))
return QMetaObject::Connection(nullptr);
#ifndef QT_NO_DEBUG
@ -3065,7 +3063,7 @@ bool QObject::disconnect(const QObject *sender, const char *signal,
}
if (res) {
if (!signal)
const_cast<QObject*>(sender)->disconnectNotify(QMetaMethod());
const_cast<QObject *>(sender)->disconnectNotify(QMetaMethod());
}
return res;
}
@ -3115,9 +3113,9 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
}
}
if (method.mobj) {
if(method.methodType() == QMetaMethod::Constructor) {
if (method.methodType() == QMetaMethod::Constructor) {
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;
}
}
@ -3125,7 +3123,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
// Reconstructing SIGNAL() macro result for signal.methodSignature() string
QByteArray signalSignature;
if (signal.mobj) {
signalSignature.reserve(signal.methodSignature().size()+1);
signalSignature.reserve(signal.methodSignature().size() + 1);
signalSignature.append((char)(QSIGNAL_CODE + '0'));
signalSignature.append(signal.methodSignature());
}
@ -3141,13 +3139,13 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
// is -1 then this signal is not a member of sender.
if (signal.mobj && signal_index == -1) {
qCWarning(lcConnect, "QObject::disconnect: signal %s not found on class %s",
signal.methodSignature().constData(), sender->metaObject()->className());
signal.methodSignature().constData(), sender->metaObject()->className());
return false;
}
// If this condition is true then method is not a member of receiver.
if (receiver && method.mobj && method_index == -1) {
qCWarning(lcConnect, "QObject::disconnect: method %s not found on class %s",
method.methodSignature().constData(), receiver->metaObject()->className());
method.methodSignature().constData(), receiver->metaObject()->className());
return false;
}
@ -3159,7 +3157,7 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal,
// QMetaObjectPrivate::disconnect() doesn't call disconnectNotify()
// per connection in this case. Call it once now, with an invalid
// QMetaMethod as argument, as documented.
const_cast<QObject*>(sender)->disconnectNotify(signal);
const_cast<QObject *>(sender)->disconnectNotify(signal);
}
return true;
}
@ -3284,7 +3282,8 @@ static int methodIndexToSignalIndex(const QMetaObject **base, int signal_index)
from the sender to the receiver's slot
*/
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();
signal_index = methodIndexToSignalIndex(&smeta, signal_index);
@ -3450,7 +3449,7 @@ bool QMetaObjectPrivate::disconnect(const QObject *sender,
QBasicMutex *senderMutex = signalSlotLock(sender);
QBasicMutexLocker locker(senderMutex);
QObjectPrivate::ConnectionData *scd = QObjectPrivate::get(s)->connections.loadRelaxed();
QObjectPrivate::ConnectionData *scd = QObjectPrivate::get(s)->connections.loadRelaxed();
if (!scd)
return false;
@ -3555,7 +3554,7 @@ void QMetaObject::connectSlotsByName(QObject *o)
// ...we check each object in our list, ...
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 QByteArray coName = co->objectName().toLatin1();
@ -3607,13 +3606,14 @@ void QMetaObject::connectSlotsByName(QObject *o)
if (foundIt) {
// we found our slot, now skip all overloads
while (mo->method(i + 1).attributes() & QMetaMethod::Cloned)
++i;
++i;
} else if (!(mo->method(i).attributes() & QMetaMethod::Cloned)) {
// check if the slot has the following signature: "on_..._...(..."
int iParen = slotSignature.indexOf('(');
int iLastUnderscore = slotSignature.lastIndexOf('_', iParen-1);
int iLastUnderscore = slotSignature.lastIndexOf('_', iParen - 1);
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;
if (!c->argumentTypes.testAndSetOrdered(nullptr, argumentTypes)) {
if (argumentTypes != &DIRECT_CONNECTION_ONLY)
delete [] argumentTypes;
delete[] argumentTypes;
argumentTypes = c->argumentTypes.loadRelaxed();
}
}
if (argumentTypes == &DIRECT_CONNECTION_ONLY) // cannot activate
return;
int nargs = 1; // include return type
while (argumentTypes[nargs-1])
while (argumentTypes[nargs - 1])
++nargs;
QBasicMutexLocker locker(signalSlotLock(c->receiver.loadRelaxed()));
@ -3665,7 +3665,7 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect
if (nargs > 1) {
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)
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);
else
doActivate<false>(sender, signal_index, argv);
}
}
/*!
\internal
@ -3962,7 +3962,7 @@ int QObjectPrivate::signalIndex(const char *signalName,
bool QObject::setProperty(const char *name, const QVariant &value)
{
Q_D(QObject);
const QMetaObject* meta = metaObject();
const QMetaObject *meta = metaObject();
if (!name || !meta)
return false;
@ -4017,7 +4017,7 @@ bool QObject::setProperty(const char *name, const QVariant &value)
QVariant QObject::property(const char *name) const
{
Q_D(const QObject);
const QMetaObject* meta = metaObject();
const QMetaObject *meta = metaObject();
if (!name || !meta)
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.
*/
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 (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);
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)
public:
QObjectData() = default;
@ -101,7 +102,7 @@ public:
uint isDeletingChildren : 1;
uint sendChildEvents : 1;
uint receiveChildEvents : 1;
uint isWindow : 1; //for QWindow
uint isWindow : 1; // for QWindow
uint deleteLaterCalled : 1;
uint unused : 24;
int postedEvents;
@ -113,7 +114,6 @@ public:
#endif
};
class Q_CORE_EXPORT QObject
{
Q_OBJECT
@ -122,7 +122,7 @@ class Q_CORE_EXPORT QObject
Q_DECLARE_PRIVATE(QObject)
public:
Q_INVOKABLE explicit QObject(QObject *parent=nullptr);
Q_INVOKABLE explicit QObject(QObject *parent = nullptr);
virtual ~QObject();
virtual bool event(QEvent *event);
@ -384,7 +384,9 @@ public:
inline QObject *parent() const { return d_ptr->parent; }
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:
void deleteLater();
@ -392,7 +394,7 @@ public Q_SLOTS:
protected:
QObject *sender() const;
int senderSignalIndex() const;
int receivers(const char* signal) const;
int receivers(const char *signal) const;
bool isSignalConnected(const QMetaMethod &signal) const;
virtual void timerEvent(QTimerEvent *event);
@ -497,9 +499,10 @@ public:
inline void reblock() noexcept;
inline void unblock() noexcept;
private:
Q_DISABLE_COPY(QSignalBlocker)
QObject * m_o;
QObject *m_o;
bool m_blocked;
bool m_inhibited;
};
@ -548,13 +551,15 @@ QSignalBlocker::~QSignalBlocker()
void QSignalBlocker::reblock() noexcept
{
if (m_o) m_o->blockSignals(true);
if (m_o)
m_o->blockSignals(true);
m_inhibited = false;
}
void QSignalBlocker::unblock() noexcept
{
if (m_o) m_o->blockSignals(m_blocked);
if (m_o)
m_o->blockSignals(m_blocked);
m_inhibited = true;
}

View File

@ -107,7 +107,7 @@ public:
QList<QByteArray> propertyNames;
QList<QVariant> propertyValues;
QList<int> runningTimers;
QList<QPointer<QObject> > eventFilters;
QList<QPointer<QObject>> eventFilters;
QString objectName;
};
@ -123,7 +123,8 @@ public:
Connection *next;
};
static SignalVector *asSignalVector(ConnectionOrSignalVector *c) {
static SignalVector *asSignalVector(ConnectionOrSignalVector *c)
{
if (reinterpret_cast<quintptr>(c) & 1)
return reinterpret_cast<SignalVector *>(reinterpret_cast<quintptr>(c) & ~quintptr(1u));
return nullptr;
@ -171,7 +172,8 @@ public:
isSlotObject = false;
}
}
void deref() {
void deref()
{
if (!ref_.deref()) {
Q_ASSERT(!receiver.loadRelaxed());
Q_ASSERT(!isSlotObject);
@ -229,8 +231,6 @@ public:
int count() const { return static_cast<int>(allocated); }
};
/*
This contains the all connections from and to an object.
@ -278,7 +278,8 @@ public:
return signalVector.loadRelaxed()->at(signal);
}
void resizeSignalVector(uint size) {
void resizeSignalVector(uint size)
{
SignalVector *vector = this->signalVector.loadRelaxed();
if (vector && vector->allocated > size)
return;
@ -300,8 +301,9 @@ public:
orphaned.storeRelaxed(ConnectionOrSignalVector::fromSignalVector(vector));
}
}
int signalVectorCount() const {
return signalVector.loadAcquire() ? signalVector.loadRelaxed()->count() : -1;
int signalVectorCount() const
{
return signalVector.loadAcquire() ? signalVector.loadRelaxed()->count() : -1;
}
static void deleteOrphaned(ConnectionOrSignalVector *c);
@ -324,9 +326,7 @@ public:
void addConnection(int signal, Connection *c);
static QObjectPrivate *get(QObject *o) {
return o->d_func();
}
static QObjectPrivate *get(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;
@ -569,15 +569,16 @@ private:
ushort method_relative_;
} d;
// 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
{
Q_DISABLE_COPY_MOVE(QBoolBlocker)
public:
explicit inline QBoolBlocker(bool &b, bool value=true):block(b), reset(b){block = value;}
inline ~QBoolBlocker(){block = reset; }
explicit inline QBoolBlocker(bool &b, bool value = true) : block(b), reset(b) { block = value; }
inline ~QBoolBlocker() { block = reset; }
private:
bool &block;
bool reset;

View File

@ -91,12 +91,12 @@ QObjectCleanupHandler::~QObjectCleanupHandler()
\sa remove()
*/
QObject *QObjectCleanupHandler::add(QObject* object)
QObject *QObjectCleanupHandler::add(QObject *object)
{
if (!object)
return nullptr;
connect(object, SIGNAL(destroyed(QObject*)), this, SLOT(objectDestroyed(QObject*)));
connect(object, SIGNAL(destroyed(QObject *)), this, SLOT(objectDestroyed(QObject *)));
cleanupObjects.insert(0, object);
return object;
}
@ -112,7 +112,7 @@ void QObjectCleanupHandler::remove(QObject *object)
int index;
if ((index = cleanupObjects.indexOf(object)) != -1) {
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
class Q_CORE_EXPORT QObjectCleanupHandler : public QObject
{
Q_OBJECT
@ -53,7 +52,7 @@ public:
QObjectCleanupHandler();
~QObjectCleanupHandler();
QObject* add(QObject* object);
QObject *add(QObject *object);
void remove(QObject *object);
bool isEmpty() const;
void clear();

View File

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

View File

@ -226,7 +226,8 @@ public:
staticObserverCallback = nullptr;
}
}
void prependObserver(QPropertyObserverPointer observer) {
void prependObserver(QPropertyObserverPointer observer)
{
observer.ptr->prev = const_cast<QPropertyObserver **>(&firstObserver.ptr);
firstObserver = observer;
}
@ -254,7 +255,8 @@ public:
heapObservers->clear();
dependencyObserverCount = 0;
}
QPropertyObserverPointer allocateDependencyObserver() {
QPropertyObserverPointer allocateDependencyObserver()
{
if (dependencyObserverCount < inlineDependencyObservers.size()) {
++dependencyObserverCount;
return {&inlineDependencyObservers[dependencyObserverCount - 1]};
@ -280,7 +282,8 @@ public:
void setError(QPropertyBindingError &&e)
{ error = std::move(e); }
void detachFromProperty() {
void detachFromProperty()
{
hasStaticObserver = false;
hasBindingWrapper = false;
propertyDataPtr = nullptr;
@ -309,17 +312,17 @@ inline void QPropertyBindingDataPointer::fixupFirstObserverAfterMove() const
if (ptr->d_ptr & QtPrivate::QPropertyBindingData::BindingBit)
return; // nothing to do if the observer is stored in the binding
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
{
if (auto *binding = bindingPtr())
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>
class QObjectCompatProperty : public QPropertyData<T>
{
@ -363,7 +366,8 @@ public:
explicit QObjectCompatProperty(const T &initialValue) : QPropertyData<T>(initialValue) {}
explicit QObjectCompatProperty(T &&initialValue) : QPropertyData<T>(std::move(initialValue)) {}
parameter_type value() const {
parameter_type value() const
{
const QBindingStorage *storage = qGetBindingStorage(owner());
// make sure we don't register this binding as a dependency to itself
if (!inBindingWrapper(storage))
@ -393,7 +397,8 @@ public:
return value();
}
void setValue(parameter_type t) {
void setValue(parameter_type t)
{
QBindingStorage *storage = qGetBindingStorage(owner());
auto *bd = storage->bindingData(this);
// 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)
{
d = reinterpret_cast<quintptr*>(ptr);
d = reinterpret_cast<quintptr *>(ptr);
return *this;
}
QTagPreservingPointerToPointer<T, Tag> &operator=(QTaggedPointer<T, Tag> *ptr)
{
d = reinterpret_cast<quintptr*>(ptr);
d = reinterpret_cast<quintptr *>(ptr);
return *this;
}

View File

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

View File

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

View File

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

View File

@ -49,7 +49,8 @@ class QSignalMapperPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QSignalMapper)
public:
void _q_senderDestroyed() {
void _q_senderDestroyed()
{
Q_Q(QSignalMapper);
q->removeMappings(q->sender());
}
@ -61,7 +62,7 @@ public:
auto it = mappedValues.find(sender);
if (it != mappedValues.end())
Q_EMIT (q->*signal)(*it);
Q_EMIT(q->*signal)(*it);
}
void emitMappedValues(QObject *sender)
@ -73,7 +74,7 @@ public:
QHash<QObject *, int> intHash;
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)
{
switch(errorScope) {
switch (errorScope) {
case NativeError:
#if defined (Q_OS_WIN)
#if defined(Q_OS_WIN)
return windowsErrorString(errorCode);
#endif // else unix: native and standard library are the same
case StandardLibraryError:

View File

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

View File

@ -658,7 +658,7 @@ static QString find_translation(const QLocale & locale,
QString lang = languages.at(i);
QString lowerLang = lang.toLower();
if (lang != lowerLang)
languages.insert(i+1, lowerLang);
languages.insert(i + 1, lowerLang);
}
#endif
@ -837,7 +837,7 @@ bool QTranslatorPrivate::do_load(const uchar *data, qsizetype len, const QString
}
if (tag == QTranslatorPrivate::Language) {
language = QString::fromUtf8((const char*)data, blockLen);
language = QString::fromUtf8((const char *)data, blockLen);
} else if (tag == QTranslatorPrivate::Contexts) {
contextArray = data;
contextLength = blockLen;
@ -906,7 +906,7 @@ static QString getMessage(const uchar *m, const uchar *end, const char *context,
uchar tag = 0;
if (m < end)
tag = read8(m++);
switch((Tag)tag) {
switch ((Tag)tag) {
case Tag_End:
goto end;
case Tag_Translation: {
@ -1015,7 +1015,7 @@ QString QTranslatorPrivate::do_translate(const char *context, const char *source
elfHash_finish(h);
const uchar *start = offsetArray;
const uchar *end = start + ((numItems-1) << 3);
const uchar *end = start + ((numItems - 1) << 3);
while (start <= end) {
const uchar *middle = start + (((end - start) >> 4) << 3);
uint hash = read32(middle);
@ -1031,7 +1031,7 @@ QString QTranslatorPrivate::do_translate(const char *context, const char *source
if (start <= end) {
// go back on equal key
while (start != offsetArray && read32(start) == read32(start-8))
while (start != offsetArray && read32(start) == read32(start - 8))
start -= 8;
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.
*/
QVariant& QVariant::operator=(const QVariant &variant)
QVariant &QVariant::operator=(const QVariant &variant)
{
if (this == &variant)
return *this;
@ -1062,7 +1062,6 @@ void QVariant::clear()
Returns \nullptr if the type is QMetaType::UnknownType or doesn't exist.
*/
/*!
\fn QVariant::Type QVariant::nameToType(const char *name)
\deprecated Use QMetaType instead
@ -1198,7 +1197,7 @@ void QVariant::load(QDataStream &s)
if (!isValid()) {
if (s.version() < QDataStream::Qt_5_0) {
// Since we wrote something, we should read something
// Since we wrote something, we should read something
QString x;
s >> x;
}
@ -1273,7 +1272,7 @@ void QVariant::save(QDataStream &s) const
typeId = 75;
} else if (typeId >= Qt5KeySequence && typeId <= Qt5QQuaternion) {
// and as a result these types received lower ids too
typeId +=1;
typeId += 1;
} else if (typeId > Qt5QQuaternion || typeId == QMetaType::QUuid) {
// These existed in Qt 4 only as a custom type
typeId = 127;
@ -1309,7 +1308,7 @@ void QVariant::save(QDataStream &s) const
\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);
return s;
@ -1320,7 +1319,7 @@ QDataStream& operator>>(QDataStream &s, QVariant &p)
\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);
return s;
@ -2221,7 +2220,8 @@ static bool integralEquals(uint promotedType, const QVariant::Private *d1, const
namespace {
template<typename Numeric>
int spaceShip(Numeric lhs, Numeric rhs) {
int spaceShip(Numeric lhs, Numeric rhs)
{
bool smaller;
if constexpr (std::is_same_v<Numeric, QObject *>)
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 *>();
}
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 *>());
}
#endif
@ -2387,19 +2388,16 @@ std::optional<int> QVariant::compare(const QVariant &lhs, const QVariant &rhs)
return t.compare(lhs.constData(), rhs.constData());
}
/*!
\fn const void *QVariant::constData() const
\fn const void* QVariant::data() const
\internal
*/
/*!
\internal
*/
void* QVariant::data()
void *QVariant::data()
{
detach();
// 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());
}
/*!
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(const QDateTime &datetime);
QVariant(const QList<QVariant> &list);
QVariant(const QMap<QString,QVariant> &map);
QVariant(const QHash<QString,QVariant> &hash);
QVariant(const QMap<QString, QVariant> &map);
QVariant(const QHash<QString, QVariant> &hash);
#ifndef QT_NO_GEOM_VARIANT
QVariant(const QSize &size);
QVariant(const QSizeF &size);
@ -414,7 +414,7 @@ class Q_CORE_EXPORT QVariant
bool canView() const
{ return canView(QMetaType::fromType<T>()); }
public:
public:
struct PrivateShared
{
private:
@ -579,14 +579,14 @@ inline bool QVariant::isValid() const
}
#ifndef QT_NO_DATASTREAM
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, QVariant &p);
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &s, const QVariant &p);
#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
QT_DEPRECATED_VERSION_6_0
inline QDataStream& operator>> (QDataStream& s, QVariant::Type &p)
inline QDataStream &operator>>(QDataStream &s, QVariant::Type &p)
{
quint32 u;
s >> u;
@ -594,7 +594,7 @@ inline QDataStream& operator>> (QDataStream& s, QVariant::Type &p)
return s;
}
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);
return s;
@ -676,7 +676,7 @@ public:
QVariantRef &operator=(const QVariantRef &value) { return operator=(QVariant(value)); }
QVariantRef &operator=(QVariantRef &&value) { return operator=(QVariant(value)); }
friend void swap(QVariantRef a, QVariantRef b)
friend void swap(QVariantRef a, QVariantRef b)
{
QVariant tmp = a;
a = b;