Let Qt handle object deletion.
This commit is contained in:
parent
7efbeab4aa
commit
a9e76830c1
|
@ -33,11 +33,6 @@ Dialog::Dialog(std::vector<Socket*> *sockets_vector, QWidget *parent) :
|
|||
ui->offTimer->setEnabled(false);
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Dialog::updateUi()
|
||||
{
|
||||
for (unsigned int i = 0; i < (*sockets).size(); ++i) {
|
||||
|
|
1
dialog.h
1
dialog.h
|
@ -31,7 +31,6 @@ class Dialog : public QDialog
|
|||
{
|
||||
public:
|
||||
explicit Dialog(std::vector<Socket*> *sockets_vector, QWidget *parent = 0);
|
||||
~Dialog();
|
||||
|
||||
void discovered();
|
||||
void updateUi();
|
||||
|
|
11
server.cpp
11
server.cpp
|
@ -27,7 +27,7 @@
|
|||
Server::Server(std::vector<Socket*> *sockets_vector)
|
||||
{
|
||||
sockets = sockets_vector;
|
||||
udpSocketGet = new QUdpSocket();
|
||||
udpSocketGet = new QUdpSocket(this);
|
||||
udpSocketGet->bind(QHostAddress::Any, 10000);
|
||||
connect(udpSocketGet, &QUdpSocket::readyRead, this, &Server::readPendingDatagrams);
|
||||
discoverSockets();
|
||||
|
@ -113,11 +113,6 @@ Server::Server(uint16_t port, QByteArray ssid, QByteArray password)
|
|||
discoverSockets();
|
||||
}
|
||||
|
||||
Server::~Server()
|
||||
{
|
||||
delete udpSocketGet;
|
||||
}
|
||||
|
||||
QByteArray Server::listen(QByteArray message)
|
||||
{
|
||||
QByteArray reply;
|
||||
|
@ -185,7 +180,7 @@ void Server::readPendingDatagrams()
|
|||
|
||||
void Server::discoverSockets()
|
||||
{
|
||||
QUdpSocket *udpSocketSend = new QUdpSocket();
|
||||
QUdpSocket *udpSocketSend = new QUdpSocket(this);
|
||||
udpSocketSend->connectToHost(QHostAddress::Broadcast, 10000);
|
||||
udpSocketSend->write(discover);
|
||||
udpSocketSend->write(discover);
|
||||
|
@ -235,4 +230,4 @@ QByteArray fives(unsigned short int length)
|
|||
QByteArray packet;
|
||||
packet.fill(0x05, length);
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
|
1
server.h
1
server.h
|
@ -31,7 +31,6 @@ class Server : public QThread
|
|||
public:
|
||||
Server(std::vector<Socket*> *sockets_vector);
|
||||
Server(uint16_t port, QByteArray ssid, QByteArray password);
|
||||
~Server();
|
||||
|
||||
void discoverSockets();
|
||||
void readPendingDatagrams();
|
||||
|
|
|
@ -51,7 +51,7 @@ Socket::Socket(QHostAddress IPaddress, QByteArray reply)
|
|||
datagram[PowerOff] = commandIDPower + mac + twenties + zeros + zero;
|
||||
datagram[ReadTable] = commandID[ReadTable] + mac + twenties + /*zeros*/QByteArray::fromHex("00 00 00 00") /*cookie*/ + QByteArray::fromHex("01 00") + zero + zeros;
|
||||
|
||||
udpSocket = new QUdpSocket();
|
||||
udpSocket = new QUdpSocket(this);
|
||||
udpSocket->connectToHost(ip, 10000);
|
||||
|
||||
connect(this, &Socket::datagramQueued, this, &Socket::processQueue);
|
||||
|
@ -64,12 +64,6 @@ Socket::Socket(QHostAddress IPaddress, QByteArray reply)
|
|||
tableData();
|
||||
}
|
||||
|
||||
Socket::~Socket()
|
||||
{
|
||||
delete subscribeTimer;
|
||||
delete udpSocket;
|
||||
}
|
||||
|
||||
void Socket::sendDatagram(Datagram d)
|
||||
{
|
||||
commands.enqueue(d);
|
||||
|
|
Loading…
Reference in New Issue