Commit 16cf1826 authored by Gus Grubba's avatar Gus Grubba

Fix typo and use Qt's builtin vector deleteAll to clear lists.

parent faee40e0
...@@ -89,7 +89,7 @@ static bool is_ip_local(const QHostAddress& add) ...@@ -89,7 +89,7 @@ static bool is_ip_local(const QHostAddress& add)
return false; return false;
} }
static bool containst_target(const QList<UDPCLient*> list, const QHostAddress& address, quint16 port) static bool contains_target(const QList<UDPCLient*> list, const QHostAddress& address, quint16 port)
{ {
foreach(UDPCLient* target, list) { foreach(UDPCLient* target, list) {
if(target->address == address && target->port == port) { if(target->address == address && target->port == port) {
...@@ -121,10 +121,8 @@ UDPLink::~UDPLink() ...@@ -121,10 +121,8 @@ UDPLink::~UDPLink()
// Tell the thread to exit // Tell the thread to exit
_running = false; _running = false;
// Clear client list // Clear client list
while(_sessionTargets.size()) { qDeleteAll(_sessionTargets);
delete _sessionTargets.last(); _sessionTargets.clear();
_sessionTargets.removeLast();
}
quit(); quit();
// Wait for it to exit // Wait for it to exit
wait(); wait();
...@@ -167,7 +165,7 @@ void UDPLink::_writeBytes(const QByteArray data) ...@@ -167,7 +165,7 @@ void UDPLink::_writeBytes(const QByteArray data)
// Send to all manually targeted systems // Send to all manually targeted systems
foreach(UDPCLient* target, _udpConfig->targetHosts()) { foreach(UDPCLient* target, _udpConfig->targetHosts()) {
// Skip it if it's part of the session clients below // Skip it if it's part of the session clients below
if(!containst_target(_sessionTargets, target->address, target->port)) { if(!contains_target(_sessionTargets, target->address, target->port)) {
_writeDataGram(data, target); _writeDataGram(data, target);
} }
} }
...@@ -218,7 +216,7 @@ void UDPLink::readBytes() ...@@ -218,7 +216,7 @@ void UDPLink::readBytes()
if(is_ip_local(sender)) { if(is_ip_local(sender)) {
asender = QHostAddress(QString("127.0.0.1")); asender = QHostAddress(QString("127.0.0.1"));
} }
if(!containst_target(_sessionTargets, asender, senderPort)) { if(!contains_target(_sessionTargets, asender, senderPort)) {
qDebug() << "Adding target" << asender << senderPort; qDebug() << "Adding target" << asender << senderPort;
UDPCLient* target = new UDPCLient(asender, senderPort); UDPCLient* target = new UDPCLient(asender, senderPort);
_sessionTargets.append(target); _sessionTargets.append(target);
...@@ -391,7 +389,7 @@ void UDPConfiguration::_copyFrom(LinkConfiguration *source) ...@@ -391,7 +389,7 @@ void UDPConfiguration::_copyFrom(LinkConfiguration *source)
_localPort = usource->localPort(); _localPort = usource->localPort();
_clearTargetHosts(); _clearTargetHosts();
foreach(UDPCLient* target, usource->targetHosts()) { foreach(UDPCLient* target, usource->targetHosts()) {
if(!containst_target(_targetHosts, target->address, target->port)) { if(!contains_target(_targetHosts, target->address, target->port)) {
UDPCLient* newTarget = new UDPCLient(target); UDPCLient* newTarget = new UDPCLient(target);
_targetHosts.append(newTarget); _targetHosts.append(newTarget);
} }
...@@ -403,10 +401,8 @@ void UDPConfiguration::_copyFrom(LinkConfiguration *source) ...@@ -403,10 +401,8 @@ void UDPConfiguration::_copyFrom(LinkConfiguration *source)
void UDPConfiguration::_clearTargetHosts() void UDPConfiguration::_clearTargetHosts()
{ {
while(_targetHosts.size()) { qDeleteAll(_targetHosts);
delete _targetHosts.last(); _targetHosts.clear();
_targetHosts.removeLast();
}
} }
/** /**
...@@ -433,7 +429,7 @@ void UDPConfiguration::addHost(const QString& host, quint16 port) ...@@ -433,7 +429,7 @@ void UDPConfiguration::addHost(const QString& host, quint16 port)
qWarning() << "UDP:" << "Could not resolve host:" << host << "port:" << port; qWarning() << "UDP:" << "Could not resolve host:" << host << "port:" << port;
} else { } else {
QHostAddress address(ipAdd); QHostAddress address(ipAdd);
if(!containst_target(_targetHosts, address, port)) { if(!contains_target(_targetHosts, address, port)) {
UDPCLient* newTarget = new UDPCLient(address, port); UDPCLient* newTarget = new UDPCLient(address, port);
_targetHosts.append(newTarget); _targetHosts.append(newTarget);
_updateHostList(); _updateHostList();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment