fix: connect refresh discon btn bug.

This commit is contained in:
2025-06-20 14:39:03 +08:00
parent 9c012b9613
commit de443ed5b2
3 changed files with 14 additions and 5 deletions

View File

@@ -48,6 +48,13 @@ bool ClientCore::Connect(const QString& ip, quint16 port)
void ClientCore::Disconnect()
{
QMutexLocker locker(&conMutex_);
if (socket_ && socket_->state() != QAbstractSocket::UnconnectedState) {
socket_->disconnectFromHost();
if (socket_->state() != QAbstractSocket::UnconnectedState) {
socket_->waitForDisconnected(1000);
}
}
connected_ = false;
}
@@ -219,9 +226,9 @@ QString ClientCore::GetOwnID()
SocketWorker::SocketWorker(ClientCore* core, QObject* parent) : QThread(parent), core_(core)
{
connect(core_, &ClientCore::sigDisconnect, this, [this]() {
thread()->quit();
});
//connect(core_, &ClientCore::sigDisconnect, this, [this]() {
// thread()->quit();
//});
}
SocketWorker::~SocketWorker()