From 6ce710f237389a6a265ee6ed26f8fe4714411a2b Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 16 Jul 2015 16:47:09 -0700 Subject: [PATCH 1/2] Fix domain request denied reason read --- interface/src/Application.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b03df3a1cc..381124789d 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3820,10 +3820,9 @@ void Application::domainChanged(const QString& domainHostname) { } void Application::handleDomainConnectionDeniedPacket(QSharedPointer packet) { - QDataStream packetStream(packet.data()); - - QString reason; - packetStream >> reason; + quint16 size; + packet->readPrimitive(&size); + QString reason = QString::fromUtf8(packet->read(size)); // output to the log so the user knows they got a denied connection request // and check and signal for an access token so that we can make sure they are logged in From ceea5143e11ec5e1571afc3f053bf406971c1af6 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Thu, 16 Jul 2015 16:55:37 -0700 Subject: [PATCH 2/2] Avoid string copy --- interface/src/Application.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 381124789d..e19ce68d39 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3820,9 +3820,11 @@ void Application::domainChanged(const QString& domainHostname) { } void Application::handleDomainConnectionDeniedPacket(QSharedPointer packet) { - quint16 size; - packet->readPrimitive(&size); - QString reason = QString::fromUtf8(packet->read(size)); + // Read deny reason from packet + quint16 reasonSize; + packet->readPrimitive(&reasonSize); + QString reason = QString::fromUtf8(packet->getPayload() + packet->pos(), reasonSize); + packet->seek(packet->pos() + reasonSize); // output to the log so the user knows they got a denied connection request // and check and signal for an access token so that we can make sure they are logged in