LocalServer crash fix
This commit is contained in:
parent
5fa2f019d0
commit
461a62e0c8
7 changed files with 28 additions and 0 deletions
|
@ -10,6 +10,7 @@ LocalServer::LocalServer(QObject *parent)
|
|||
|
||||
LocalServer::~LocalServer()
|
||||
{
|
||||
prepareDestroy();
|
||||
}
|
||||
|
||||
LocalServerInterface *LocalServer::newConnection()
|
||||
|
|
|
@ -32,8 +32,18 @@ Server::Server(QObject *parent)
|
|||
|
||||
Server::~Server()
|
||||
{
|
||||
}
|
||||
|
||||
void Server::prepareDestroy()
|
||||
{
|
||||
QMutexLocker locker(&serverMutex);
|
||||
|
||||
while (!clients.isEmpty())
|
||||
delete clients.takeFirst();
|
||||
|
||||
QMapIterator<int, Server_Room *> roomIterator(rooms);
|
||||
while (roomIterator.hasNext())
|
||||
delete roomIterator.next().value();
|
||||
}
|
||||
|
||||
AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString &name, const QString &password)
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
virtual QMap<QString, ServerInfo_User *> getIgnoreList(const QString &name) = 0;
|
||||
virtual bool getUserBanned(Server_ProtocolHandler * /*client*/, const QString & /*userName*/) const { return false; }
|
||||
protected:
|
||||
void prepareDestroy();
|
||||
QList<Server_ProtocolHandler *> clients;
|
||||
QMap<QString, Server_ProtocolHandler *> users;
|
||||
QMap<int, Server_Room *> rooms;
|
||||
|
|
|
@ -29,6 +29,7 @@ Server_ProtocolHandler::~Server_ProtocolHandler()
|
|||
void Server_ProtocolHandler::prepareDestroy()
|
||||
{
|
||||
QMutexLocker locker(&server->serverMutex);
|
||||
qDebug("Server_ProtocolHandler::prepareDestroy");
|
||||
|
||||
server->removeClient(this);
|
||||
|
||||
|
|
|
@ -8,6 +8,19 @@ Server_Room::Server_Room(int _id, const QString &_name, const QString &_descript
|
|||
{
|
||||
}
|
||||
|
||||
Server_Room::~Server_Room()
|
||||
{
|
||||
QMutexLocker locker(&roomMutex);
|
||||
qDebug("Server_Room destructor");
|
||||
|
||||
const QList<Server_Game *> gameList = games.values();
|
||||
for (int i = 0; i < gameList.size(); ++i)
|
||||
delete gameList[i];
|
||||
games.clear();
|
||||
|
||||
clear();
|
||||
}
|
||||
|
||||
Server *Server_Room::getServer() const
|
||||
{
|
||||
return static_cast<Server *>(parent());
|
||||
|
|
|
@ -29,6 +29,7 @@ private:
|
|||
public:
|
||||
mutable QMutex roomMutex;
|
||||
Server_Room(int _id, const QString &_name, const QString &_description, bool _autoJoin, const QString &_joinMessage, const QStringList &_gameTypes, Server *parent);
|
||||
~Server_Room();
|
||||
int getId() const { return id; }
|
||||
QString getName() const { return name; }
|
||||
QString getDescription() const { return description; }
|
||||
|
|
|
@ -107,6 +107,7 @@ Servatrice::Servatrice(QSettings *_settings, QObject *parent)
|
|||
|
||||
Servatrice::~Servatrice()
|
||||
{
|
||||
prepareDestroy();
|
||||
}
|
||||
|
||||
bool Servatrice::openDatabase()
|
||||
|
|
Loading…
Reference in a new issue