From 15ca129005ecf702974ff2052f7d3cb1d11fdc3b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 14 Jul 2015 16:46:17 -0700 Subject: [PATCH 1/2] fix for registration of methods with typedef --- domain-server/src/DomainServer.cpp | 2 +- libraries/networking/src/PacketReceiver.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index dbcf65e192..0a407e6f53 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -282,7 +282,7 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) { // register as the packet receiver for the types we want PacketReceiver& packetReceiver = nodeList->getPacketReceiver(); packetReceiver.registerListener(PacketType::RequestAssignment, this, "processRequestAssignmentPacket"); - packetReceiver.registerListener(PacketType::DomainConnectRequest, this, "processConnectRequestPackets"); + packetReceiver.registerListener(PacketType::DomainConnectRequest, this, "processConnectRequestPacket"); packetReceiver.registerListener(PacketType::DomainListRequest, this, "processListRequestPacket"); packetReceiver.registerListener(PacketType::DomainServerPathQuery, this, "processPathQueryPacket"); packetReceiver.registerListener(PacketType::NodeJsonStats, this, "processNodeJSONStatsPacket"); diff --git a/libraries/networking/src/PacketReceiver.cpp b/libraries/networking/src/PacketReceiver.cpp index 354c04d659..f9fe5a9c23 100644 --- a/libraries/networking/src/PacketReceiver.cpp +++ b/libraries/networking/src/PacketReceiver.cpp @@ -75,11 +75,13 @@ QMetaMethod PacketReceiver::matchingMethodForListener(PacketType::Value type, QO QSet possibleSignatures { QString("%1(%2)").arg(slot).arg(NON_SOURCED_PACKET_LISTENER_PARAMETERS) }; if (!NON_SOURCED_PACKETS.contains(type)) { - const QString SOURCED_PACKET_LISTENER_PARAMETERS = "QSharedPointer,QSharedPointer"; + static const QString SOURCED_PACKET_LISTENER_PARAMETERS = "QSharedPointer,QSharedPointer"; + static const QString TYPEDEF_SOURCED_PACKET_LISTENER_PARAMETERS = "QSharedPointer,SharedNodePointer"; // a sourced packet must take the shared pointer to the packet but optionally could include // a shared pointer to the node + possibleSignatures << QString("%1(%2)").arg(slot).arg(TYPEDEF_SOURCED_PACKET_LISTENER_PARAMETERS); possibleSignatures << QString("%1(%2)").arg(slot).arg(SOURCED_PACKET_LISTENER_PARAMETERS); } @@ -88,11 +90,13 @@ QMetaMethod PacketReceiver::matchingMethodForListener(PacketType::Value type, QO foreach(const QString& signature, possibleSignatures) { QByteArray normalizedSlot = QMetaObject::normalizedSignature(signature.toStdString().c_str()); - + // does the constructed normalized method exist? methodIndex = object->metaObject()->indexOfSlot(normalizedSlot.toStdString().c_str()); - break; + if (methodIndex >= 0) { + break; + } } if (methodIndex < 0) { @@ -100,7 +104,7 @@ QMetaMethod PacketReceiver::matchingMethodForListener(PacketType::Value type, QO << possibleSignatures.toList() << "- but such a method was not found."; } - Q_ASSERT(methodIndex >= 0); + assert(methodIndex >= 0); // return the converted QMetaMethod if (methodIndex >= 0) { From 251387159a32b0a15dc4158f26780d61253e1fd2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 14 Jul 2015 16:48:55 -0700 Subject: [PATCH 2/2] go back to Q_ASSERT for methodIndex --- libraries/networking/src/PacketReceiver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/networking/src/PacketReceiver.cpp b/libraries/networking/src/PacketReceiver.cpp index f9fe5a9c23..462678d76a 100644 --- a/libraries/networking/src/PacketReceiver.cpp +++ b/libraries/networking/src/PacketReceiver.cpp @@ -104,7 +104,7 @@ QMetaMethod PacketReceiver::matchingMethodForListener(PacketType::Value type, QO << possibleSignatures.toList() << "- but such a method was not found."; } - assert(methodIndex >= 0); + Q_ASSERT(methodIndex >= 0); // return the converted QMetaMethod if (methodIndex >= 0) {