From 79ac713dff871c516a60b6c40d68f194e6e40d29 Mon Sep 17 00:00:00 2001 From: Tim Murray-Browne Date: Mon, 5 Oct 2015 12:02:10 +0100 Subject: [PATCH 1/2] Fix issue #4 where strings with a length divisible by four are parsed in a way that can prevent subsequent string arguments being correctly parsed. --- libofqf/qoscserver.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libofqf/qoscserver.cpp b/libofqf/qoscserver.cpp index eaf65e4..95d7618 100644 --- a/libofqf/qoscserver.cpp +++ b/libofqf/qoscserver.cpp @@ -87,7 +87,8 @@ void QOscServer::readyRead() { if ( type == 's' ) { QString s = toString( tmp ); value = s; - i += s.size(); + // string size plus one for the null terminator + i += s.size() + 1; } if ( type == 'i' ) { value = toInt32( tmp ); From 7c879f4045798a91c9f16f0b7216474ef7d55bb8 Mon Sep 17 00:00:00 2001 From: Tim Murray-Browne Date: Mon, 5 Oct 2015 12:12:02 +0100 Subject: [PATCH 2/2] Unregister path objects in destructor of QOSCServer. Otherwise the path objects will attempt to unregister themselves when they are destroyed by QOSCServer's base (as they are children of QOSCServer), but this happens in ~QObject after QOSCServer::path has been destroyed by ~QOSCServer. --- libofqf/qoscserver.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libofqf/qoscserver.cpp b/libofqf/qoscserver.cpp index 95d7618..c11d8d2 100644 --- a/libofqf/qoscserver.cpp +++ b/libofqf/qoscserver.cpp @@ -39,6 +39,12 @@ QOscServer::QOscServer( QHostAddress address, quint16 port, QObject* p ) QOscServer::~QOscServer() { qDebug() << "QOscServer::~QOscServer()"; + // manually destroy child path objects here as they need to unregister themselves + // before `paths` gets destroyed at the end of this function + for (PathObject* pathObject : findChildren("", Qt::FindDirectChildrenOnly)) + { + delete pathObject; + } } void QOscServer::registerPathObject( PathObject* p ) {