diff --git a/common/server_protocolhandler.cpp b/common/server_protocolhandler.cpp index dc74ad62..355ccdaf 100644 --- a/common/server_protocolhandler.cpp +++ b/common/server_protocolhandler.cpp @@ -24,11 +24,12 @@ Server_ProtocolHandler::~Server_ProtocolHandler() } // This is essentially the destructor, but it needs to be called from the -// child's destructor with the server mutex locked. Otherwise, the mutex -// could get unlocked while the object is not finished being destroyed, -// leading to calls to pure virtual functions. +// child's destructor so that the server mutex does not get unlocked during +// finalization. void Server_ProtocolHandler::prepareDestroy() { + QMutexLocker locker(&server->serverMutex); + server->removeClient(this); QMapIterator roomIterator(rooms); diff --git a/servatrice/src/serversocketinterface.cpp b/servatrice/src/serversocketinterface.cpp index 79ef89ea..f02747ca 100644 --- a/servatrice/src/serversocketinterface.cpp +++ b/servatrice/src/serversocketinterface.cpp @@ -60,7 +60,6 @@ ServerSocketInterface::ServerSocketInterface(Servatrice *_server, QTcpSocket *_s ServerSocketInterface::~ServerSocketInterface() { - QMutexLocker locker(&servatrice->serverMutex); logger->logMessage("ServerSocketInterface destructor"); prepareDestroy();