From 7cb31cc8afc5006e650f30476fb986c408e9630c Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sun, 8 May 2022 18:45:22 +0100 Subject: [PATCH] Update udphandler.cpp --- udphandler.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/udphandler.cpp b/udphandler.cpp index 5084ee9..2413bc0 100644 --- a/udphandler.cpp +++ b/udphandler.cpp @@ -90,10 +90,12 @@ udpHandler::~udpHandler() if (streamOpened) { if (audio != Q_NULLPTR) { delete audio; + audio = Q_NULLPTR; } if (civ != Q_NULLPTR) { delete civ; + civ = Q_NULLPTR; } qInfo(logUdp()) << "Sending token removal packet"; sendToken(0x01); @@ -282,7 +284,7 @@ void udpHandler::dataReceived() delete civ; civ = Q_NULLPTR; } - + streamOpened = false; } } @@ -474,6 +476,20 @@ void udpHandler::dataReceived() void udpHandler::setCurrentRadio(quint8 radio) { + + // If we are currently connected to a different radio, disconnect first + if (audio != Q_NULLPTR) { + delete audio; + audio = Q_NULLPTR; + } + + if (civ != Q_NULLPTR) { + delete civ; + civ = Q_NULLPTR; + } + + streamOpened = false; + qInfo(logUdp()) << "Got Radio" << radio; qInfo(logUdp()) << "Find available local ports";