return _classInfo[obj->metaObject()]->argTypes[methodId];
}
+void SignalProxy::setMinArgCount(QObject *obj, int methodId) {
+ const QMetaObject *meta = obj->metaObject();
+ QString signature(meta->method(methodId).signature());
+ int minCount = meta->method(methodId).parameterTypes().count() - signature.count("=");
+ Q_ASSERT(!_classInfo[meta]->minArgCount.contains(methodId));
+ _classInfo[meta]->minArgCount[methodId] = minCount;
+}
+
+const int &SignalProxy::minArgCount(QObject *obj, int methodId) {
+ Q_ASSERT(_classInfo.contains(obj->metaObject()));
+ if(!_classInfo[obj->metaObject()]->minArgCount.contains(methodId))
+ setMinArgCount(obj, methodId);
+ return _classInfo[obj->metaObject()]->minArgCount[methodId];
+}
+
void SignalProxy::setMethodName(QObject *obj, int methodId) {
const QMetaObject *meta = obj->metaObject();
QByteArray method(::methodName(meta->method(methodId)));
bool SignalProxy::invokeSlot(QObject *receiver, int methodId, const QVariantList ¶ms) {
const QList<int> args = argTypes(receiver, methodId);
- const int numArgs = args.count();
+ const int numArgs = params.count() < args.count()
+ ? params.count()
+ : args.count();
- if(numArgs < params.count()) {
+ if(minArgCount(receiver, methodId) < params.count()) {
qWarning() << "SignalProxy::invokeSlot(): not enough params to invoke" << methodName(receiver, methodId);
return false;
}
static QString methodBaseName(const QMetaMethod &method);
const QList<int> &argTypes(QObject *obj, int methodId);
+ const int &minArgCount(QObject *obj, int methodId);
const QByteArray &methodName(QObject *obj, int methodId);
const QHash<QByteArray, int> &syncMap(SyncableObject *obj);
int updatedRemotelyId(SyncableObject *obj);
typedef QHash<int, QByteArray> MethodNameHash;
struct ClassInfo {
ArgHash argTypes;
+ QHash<int, int> minArgCount;
MethodNameHash methodNames;
int updatedRemotelyId; // id of the updatedRemotely() signal - makes things faster
QHash<QByteArray, int> syncMap;
void createClassInfo(QObject *obj);
void setArgTypes(QObject *obj, int methodId);
+ void setMinArgCount(QObject *obj, int methodId);
void setMethodName(QObject *obj, int methodId);
void setSyncMap(SyncableObject *obj);
void setUpdatedRemotelyId(QObject *obj);