fix memory leak in websockets
This commit is contained in:
parent
14f442be6c
commit
d2fec1cce9
@ -27,6 +27,7 @@ AOClient::AOClient(Server* p_server, QTcpSocket* p_socket, QObject* parent)
|
|||||||
current_area = 0;
|
current_area = 0;
|
||||||
current_char = "";
|
current_char = "";
|
||||||
remote_ip = p_socket->peerAddress();
|
remote_ip = p_socket->peerAddress();
|
||||||
|
is_partial = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::clientData()
|
void AOClient::clientData()
|
||||||
|
@ -43,10 +43,14 @@ void WSClient::onTcpData()
|
|||||||
|
|
||||||
void WSClient::onWsDisconnect()
|
void WSClient::onWsDisconnect()
|
||||||
{
|
{
|
||||||
tcp_socket->disconnectFromHost();
|
if (tcp_socket != nullptr)
|
||||||
|
tcp_socket->disconnectFromHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WSClient::onTcpDisconnect()
|
void WSClient::onTcpDisconnect()
|
||||||
{
|
{
|
||||||
|
qDebug() << "deleted";
|
||||||
web_socket->close();
|
web_socket->close();
|
||||||
|
tcp_socket->deleteLater();
|
||||||
|
web_socket->deleteLater();
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ void WSProxy::wsConnected()
|
|||||||
connect(new_ws, &QWebSocket::textMessageReceived, client, &WSClient::onWsData);
|
connect(new_ws, &QWebSocket::textMessageReceived, client, &WSClient::onWsData);
|
||||||
connect(new_tcp, &QTcpSocket::readyRead, client, &WSClient::onTcpData);
|
connect(new_tcp, &QTcpSocket::readyRead, client, &WSClient::onTcpData);
|
||||||
connect(new_ws, &QWebSocket::disconnected, client, &WSClient::onWsDisconnect);
|
connect(new_ws, &QWebSocket::disconnected, client, &WSClient::onWsDisconnect);
|
||||||
connect(new_tcp, &QTcpSocket::disconnected, client, &WSClient::onTcpDisconnect);
|
|
||||||
connect(new_tcp, &QTcpSocket::disconnected, this, [=] {
|
connect(new_tcp, &QTcpSocket::disconnected, this, [=] {
|
||||||
|
client->onTcpDisconnect();
|
||||||
clients.removeAll(client);
|
clients.removeAll(client);
|
||||||
client->deleteLater();
|
client->deleteLater();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user