summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetaobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
-rw-r--r--src/corelib/kernel/qmetaobject.cpp63
1 files changed, 25 insertions, 38 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 51866a1867..5cb30a74ac 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -348,7 +348,7 @@ const char *QMetaObject::className() const
\since 5.7
*/
-bool QMetaObject::inherits(const QMetaObject *metaObject) const Q_DECL_NOEXCEPT
+bool QMetaObject::inherits(const QMetaObject *metaObject) const noexcept
{
const QMetaObject *m = this;
do {
@@ -821,6 +821,7 @@ int QMetaObjectPrivate::indexOfConstructor(const QMetaObject *m, const QByteArra
}
/*!
+ \fn int QMetaObjectPrivate::signalOffset(const QMetaObject *m)
\internal
\since 5.0
@@ -830,14 +831,6 @@ int QMetaObjectPrivate::indexOfConstructor(const QMetaObject *m, const QByteArra
Similar to QMetaObject::methodOffset(), but non-signal methods are
excluded.
*/
-int QMetaObjectPrivate::signalOffset(const QMetaObject *m)
-{
- Q_ASSERT(m != 0);
- int offset = 0;
- for (m = m->d.superdata; m; m = m->d.superdata)
- offset += priv(m->d.data)->signalCount;
- return offset;
-}
/*!
\internal
@@ -960,7 +953,7 @@ static const QMetaObject *QMetaObject_findMetaObject(const QMetaObject *self, co
return self;
if (self->d.relatedMetaObjects) {
Q_ASSERT(priv(self->d.data)->revision >= 2);
- const QMetaObject * const *e = self->d.relatedMetaObjects;
+ const auto *e = self->d.relatedMetaObjects;
if (e) {
while (*e) {
if (const QMetaObject *m =QMetaObject_findMetaObject((*e), name))
@@ -1549,21 +1542,14 @@ bool QMetaObject::invokeMethodImpl(QObject *object, QtPrivate::QSlotObjectBase *
return false;
}
- // args and typesCopy will be deallocated by ~QMetaCallEvent() using free()
- void **args = static_cast<void **>(calloc(1, sizeof(void *)));
- Q_CHECK_PTR(args);
-
- int *types = static_cast<int *>(calloc(1, sizeof(int)));
- Q_CHECK_PTR(types);
-
- QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 1, types, args));
+ QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 1));
} else if (type == Qt::BlockingQueuedConnection) {
#if QT_CONFIG(thread)
if (currentThread == objectThread)
qWarning("QMetaObject::invokeMethod: Dead lock detected");
QSemaphore semaphore;
- QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, 0, 0, argv, &semaphore));
+ QCoreApplication::postEvent(object, new QMetaCallEvent(slot, 0, -1, argv, &semaphore));
semaphore.acquire();
#endif // QT_CONFIG(thread)
} else {
@@ -2317,42 +2303,31 @@ bool QMetaMethod::invoke(QObject *object,
return false;
}
- int nargs = 1; // include return type
- void **args = (void **) malloc(paramCount * sizeof(void *));
- Q_CHECK_PTR(args);
- int *types = (int *) malloc(paramCount * sizeof(int));
- Q_CHECK_PTR(types);
- types[0] = 0; // return type
- args[0] = 0;
+ QScopedPointer<QMetaCallEvent> event(new QMetaCallEvent(idx_offset, idx_relative, callFunction, 0, -1, paramCount));
+ int *types = event->types();
+ void **args = event->args();
+ int argIndex = 0;
for (int i = 1; i < paramCount; ++i) {
types[i] = QMetaType::type(typeNames[i]);
if (types[i] == QMetaType::UnknownType && param[i]) {
// Try to register the type and try again before reporting an error.
- int index = nargs - 1;
- void *argv[] = { &types[i], &index };
+ void *argv[] = { &types[i], &argIndex };
QMetaObject::metacall(object, QMetaObject::RegisterMethodArgumentMetaType,
idx_relative + idx_offset, argv);
if (types[i] == -1) {
qWarning("QMetaMethod::invoke: Unable to handle unregistered datatype '%s'",
typeNames[i]);
- for (int x = 1; x < i; ++x) {
- if (types[x] && args[x])
- QMetaType::destroy(types[x], args[x]);
- }
- free(types);
- free(args);
return false;
}
}
if (types[i] != QMetaType::UnknownType) {
args[i] = QMetaType::create(types[i], param[i]);
- ++nargs;
+ ++argIndex;
}
}
- QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
- 0, -1, nargs, types, args));
+ QCoreApplication::postEvent(object, event.take());
} else { // blocking queued connection
#if QT_CONFIG(thread)
QThread *currentThread = QThread::currentThread();
@@ -2365,7 +2340,7 @@ bool QMetaMethod::invoke(QObject *object,
QSemaphore semaphore;
QCoreApplication::postEvent(object, new QMetaCallEvent(idx_offset, idx_relative, callFunction,
- 0, -1, 0, 0, param, &semaphore));
+ 0, -1, param, &semaphore));
semaphore.acquire();
#endif // QT_CONFIG(thread)
}
@@ -3030,6 +3005,18 @@ int QMetaProperty::propertyIndex() const
}
/*!
+ \since 5.14
+
+ Returns this property's index relative within the enclosing meta object.
+*/
+int QMetaProperty::relativePropertyIndex() const
+{
+ if (!mobj)
+ return -1;
+ return idx;
+}
+
+/*!
Returns \c true if the property's type is an enumeration value that
is used as a flag; otherwise returns \c false.