X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Fsignalproxy.cpp;h=764ac7d4b6541e45d1a6116b4e07b0551ed25905;hp=1127005cbc2bbbb59d2f6d770a4b61f30fe50e9d;hb=a0754f069472a0ef611c191801d9f52b6357ef50;hpb=7df7429c009d2bea4c516e87f1ec4c956c722e09 diff --git a/src/common/signalproxy.cpp b/src/common/signalproxy.cpp index 1127005c..764ac7d4 100644 --- a/src/common/signalproxy.cpp +++ b/src/common/signalproxy.cpp @@ -337,6 +337,21 @@ const QList &SignalProxy::argTypes(QObject *obj, int methodId) { 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))); @@ -684,9 +699,11 @@ void SignalProxy::handleSignal(const QByteArray &funcName, const QVariantList &p bool SignalProxy::invokeSlot(QObject *receiver, int methodId, const QVariantList ¶ms) { const QList 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; }