Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
461a62e0
Commit
461a62e0
authored
May 08, 2011
by
Max-Wilhelm Bruker
Browse files
LocalServer crash fix
parent
5fa2f019
Changes
7
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/localserver.cpp
View file @
461a62e0
...
@@ -10,6 +10,7 @@ LocalServer::LocalServer(QObject *parent)
...
@@ -10,6 +10,7 @@ LocalServer::LocalServer(QObject *parent)
LocalServer
::~
LocalServer
()
LocalServer
::~
LocalServer
()
{
{
prepareDestroy
();
}
}
LocalServerInterface
*
LocalServer
::
newConnection
()
LocalServerInterface
*
LocalServer
::
newConnection
()
...
...
common/server.cpp
View file @
461a62e0
...
@@ -32,8 +32,18 @@ Server::Server(QObject *parent)
...
@@ -32,8 +32,18 @@ Server::Server(QObject *parent)
Server
::~
Server
()
Server
::~
Server
()
{
{
}
void
Server
::
prepareDestroy
()
{
QMutexLocker
locker
(
&
serverMutex
);
while
(
!
clients
.
isEmpty
())
while
(
!
clients
.
isEmpty
())
delete
clients
.
takeFirst
();
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
)
AuthenticationResult
Server
::
loginUser
(
Server_ProtocolHandler
*
session
,
QString
&
name
,
const
QString
&
password
)
...
...
common/server.h
View file @
461a62e0
...
@@ -45,6 +45,7 @@ public:
...
@@ -45,6 +45,7 @@ public:
virtual
QMap
<
QString
,
ServerInfo_User
*>
getIgnoreList
(
const
QString
&
name
)
=
0
;
virtual
QMap
<
QString
,
ServerInfo_User
*>
getIgnoreList
(
const
QString
&
name
)
=
0
;
virtual
bool
getUserBanned
(
Server_ProtocolHandler
*
/*client*/
,
const
QString
&
/*userName*/
)
const
{
return
false
;
}
virtual
bool
getUserBanned
(
Server_ProtocolHandler
*
/*client*/
,
const
QString
&
/*userName*/
)
const
{
return
false
;
}
protected:
protected:
void
prepareDestroy
();
QList
<
Server_ProtocolHandler
*>
clients
;
QList
<
Server_ProtocolHandler
*>
clients
;
QMap
<
QString
,
Server_ProtocolHandler
*>
users
;
QMap
<
QString
,
Server_ProtocolHandler
*>
users
;
QMap
<
int
,
Server_Room
*>
rooms
;
QMap
<
int
,
Server_Room
*>
rooms
;
...
...
common/server_protocolhandler.cpp
View file @
461a62e0
...
@@ -29,6 +29,7 @@ Server_ProtocolHandler::~Server_ProtocolHandler()
...
@@ -29,6 +29,7 @@ Server_ProtocolHandler::~Server_ProtocolHandler()
void
Server_ProtocolHandler
::
prepareDestroy
()
void
Server_ProtocolHandler
::
prepareDestroy
()
{
{
QMutexLocker
locker
(
&
server
->
serverMutex
);
QMutexLocker
locker
(
&
server
->
serverMutex
);
qDebug
(
"Server_ProtocolHandler::prepareDestroy"
);
server
->
removeClient
(
this
);
server
->
removeClient
(
this
);
...
...
common/server_room.cpp
View file @
461a62e0
...
@@ -8,6 +8,19 @@ Server_Room::Server_Room(int _id, const QString &_name, const QString &_descript
...
@@ -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
Server
*
Server_Room
::
getServer
()
const
{
{
return
static_cast
<
Server
*>
(
parent
());
return
static_cast
<
Server
*>
(
parent
());
...
...
common/server_room.h
View file @
461a62e0
...
@@ -29,6 +29,7 @@ private:
...
@@ -29,6 +29,7 @@ private:
public:
public:
mutable
QMutex
roomMutex
;
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
_id
,
const
QString
&
_name
,
const
QString
&
_description
,
bool
_autoJoin
,
const
QString
&
_joinMessage
,
const
QStringList
&
_gameTypes
,
Server
*
parent
);
~
Server_Room
();
int
getId
()
const
{
return
id
;
}
int
getId
()
const
{
return
id
;
}
QString
getName
()
const
{
return
name
;
}
QString
getName
()
const
{
return
name
;
}
QString
getDescription
()
const
{
return
description
;
}
QString
getDescription
()
const
{
return
description
;
}
...
...
servatrice/src/servatrice.cpp
View file @
461a62e0
...
@@ -107,6 +107,7 @@ Servatrice::Servatrice(QSettings *_settings, QObject *parent)
...
@@ -107,6 +107,7 @@ Servatrice::Servatrice(QSettings *_settings, QObject *parent)
Servatrice
::~
Servatrice
()
Servatrice
::~
Servatrice
()
{
{
prepareDestroy
();
}
}
bool
Servatrice
::
openDatabase
()
bool
Servatrice
::
openDatabase
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment