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
a319ce3a
Commit
a319ce3a
authored
Apr 01, 2012
by
Max-Wilhelm Bruker
Browse files
fix for rare condition when the game screen would remain white when the game starts
parent
40fbbc59
Changes
6
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/abstractclient.cpp
View file @
a319ce3a
...
...
@@ -44,7 +44,7 @@ AbstractClient::AbstractClient(QObject *parent)
qRegisterMetaType
<
QList
<
ServerInfo_User
>
>
(
"QList<ServerInfo_User>"
);
qRegisterMetaType
<
Event_ReplayAdded
>
(
"Event_ReplayAdded"
);
connect
(
this
,
SIGNAL
(
sig
SendCommandContainer
(
CommandContainer
)),
this
,
SLOT
(
sendCommandContainer
(
CommandContainer
)));
connect
(
this
,
SIGNAL
(
sig
QueuePendingCommand
(
PendingCommand
*
)),
this
,
SLOT
(
queuePendingCommand
(
PendingCommand
*
)));
}
AbstractClient
::~
AbstractClient
()
...
...
@@ -58,12 +58,10 @@ void AbstractClient::processProtocolItem(const ServerMessage &item)
const
Response
&
response
=
item
.
response
();
const
int
cmdId
=
response
.
cmd_id
();
QMutexLocker
locker
(
&
clientMutex
);
PendingCommand
*
pend
=
pendingCommands
.
value
(
cmdId
,
0
);
if
(
!
pend
)
return
;
pendingCommands
.
remove
(
cmdId
);
locker
.
unlock
();
pend
->
processResponse
(
response
);
pend
->
deleteLater
();
...
...
@@ -100,6 +98,7 @@ void AbstractClient::processProtocolItem(const ServerMessage &item)
void
AbstractClient
::
setStatus
(
const
ClientStatus
_status
)
{
QMutexLocker
locker
(
&
clientMutex
);
if
(
_status
!=
status
)
{
status
=
_status
;
emit
statusChanged
(
_status
);
...
...
@@ -113,15 +112,19 @@ void AbstractClient::sendCommand(const CommandContainer &cont)
void
AbstractClient
::
sendCommand
(
PendingCommand
*
pend
)
{
pend
->
moveToThread
(
thread
());
emit
sigQueuePendingCommand
(
pend
);
}
void
AbstractClient
::
queuePendingCommand
(
PendingCommand
*
pend
)
{
// This function is always called from the client thread via signal/slot.
const
int
cmdId
=
nextCmdId
++
;
pend
->
getCommandContainer
().
set_cmd_id
(
cmdId
);
pend
->
moveToThread
(
thread
());
clientMutex
.
lock
();
pendingCommands
.
insert
(
cmdId
,
pend
);
clientMutex
.
unlock
();
emit
sigS
endCommandContainer
(
pend
->
getCommandContainer
());
s
endCommandContainer
(
pend
->
getCommandContainer
());
}
PendingCommand
*
AbstractClient
::
prepareSessionCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
)
...
...
cockatrice/src/abstractclient.h
View file @
a319ce3a
...
...
@@ -60,23 +60,25 @@ signals:
void
ignoreListReceived
(
const
QList
<
ServerInfo_User
>
&
ignoreList
);
void
replayAddedEventReceived
(
const
Event_ReplayAdded
&
event
);
void
sig
SendCommandContainer
(
const
CommandContainer
&
commandContainer
);
void
sig
QueuePendingCommand
(
PendingCommand
*
pend
);
private:
int
nextCmdId
;
QMutex
clientMutex
;
mutable
QMutex
clientMutex
;
ClientStatus
status
;
private
slots
:
void
queuePendingCommand
(
PendingCommand
*
pend
);
protected
slots
:
void
processProtocolItem
(
const
ServerMessage
&
item
);
virtual
void
sendCommandContainer
(
const
CommandContainer
&
cont
)
=
0
;
protected:
QMap
<
int
,
PendingCommand
*>
pendingCommands
;
ClientStatus
status
;
QString
userName
,
password
;
void
setStatus
(
ClientStatus
_status
);
virtual
void
sendCommandContainer
(
const
CommandContainer
&
cont
)
=
0
;
public:
AbstractClient
(
QObject
*
parent
=
0
);
~
AbstractClient
();
ClientStatus
getStatus
()
const
{
return
status
;
}
ClientStatus
getStatus
()
const
{
QMutexLocker
locker
(
&
clientMutex
);
return
status
;
}
void
sendCommand
(
const
CommandContainer
&
cont
);
void
sendCommand
(
PendingCommand
*
pend
);
...
...
cockatrice/src/gamescene.cpp
View file @
a319ce3a
...
...
@@ -13,11 +13,13 @@
#include
<QGraphicsView>
GameScene
::
GameScene
(
PhasesToolbar
*
_phasesToolbar
,
QObject
*
parent
)
:
QGraphicsScene
(
parent
),
phasesToolbar
(
_phasesToolbar
)
:
QGraphicsScene
(
parent
),
phasesToolbar
(
_phasesToolbar
)
,
viewSize
(
QSize
())
{
animationTimer
=
new
QBasicTimer
;
addItem
(
phasesToolbar
);
connect
(
settingsCache
,
SIGNAL
(
minPlayersForMultiColumnLayoutChanged
()),
this
,
SLOT
(
rearrange
()));
rearrange
();
}
GameScene
::~
GameScene
()
...
...
cockatrice/src/gameview.cpp
View file @
a319ce3a
...
...
@@ -8,7 +8,7 @@ GameView::GameView(QGraphicsScene *scene, QWidget *parent)
:
QGraphicsView
(
scene
,
parent
),
rubberBand
(
0
)
{
setBackgroundBrush
(
QBrush
(
QColor
(
0
,
0
,
0
)));
setRenderHints
(
QPainter
::
TextAntialiasing
|
QPainter
::
Antialiasing
/* | QPainter::SmoothPixmapTransform*/
);
setRenderHints
(
QPainter
::
TextAntialiasing
|
QPainter
::
Antialiasing
);
setFocusPolicy
(
Qt
::
NoFocus
);
setViewportUpdateMode
(
BoundingRectViewportUpdate
);
...
...
@@ -31,9 +31,9 @@ void GameView::resizeEvent(QResizeEvent *event)
QGraphicsView
::
resizeEvent
(
event
);
GameScene
*
s
=
dynamic_cast
<
GameScene
*>
(
scene
());
if
(
s
)
{
if
(
s
)
s
->
processViewSizeChange
(
event
->
size
());
}
updateSceneRect
(
scene
()
->
sceneRect
());
}
...
...
cockatrice/src/remoteclient.cpp
View file @
a319ce3a
...
...
@@ -125,7 +125,7 @@ void RemoteClient::readData()
processProtocolItem
(
newServerMessage
);
}
while
(
!
inputBuffer
.
isEmpty
());
if
(
s
tatus
==
StatusDisconnecting
)
if
(
getS
tatus
()
==
StatusDisconnecting
)
// use thread-safe getter
doDisconnectFromServer
();
}
...
...
cockatrice/src/tab_game.cpp
View file @
a319ce3a
...
...
@@ -271,7 +271,6 @@ TabGame::TabGame(GameReplay *_replay)
}
phasesToolbar
=
new
PhasesToolbar
;
phasesToolbar
->
hide
();
scene
=
new
GameScene
(
phasesToolbar
,
this
);
gameView
=
new
GameView
(
scene
);
...
...
@@ -399,7 +398,6 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
gameTimer
->
start
();
phasesToolbar
=
new
PhasesToolbar
;
phasesToolbar
->
hide
();
connect
(
phasesToolbar
,
SIGNAL
(
sendGameCommand
(
const
::
google
::
protobuf
::
Message
&
,
int
)),
this
,
SLOT
(
sendGameCommand
(
const
::
google
::
protobuf
::
Message
&
,
int
)));
scene
=
new
GameScene
(
phasesToolbar
,
this
);
...
...
@@ -869,7 +867,6 @@ void TabGame::startGame(bool resuming)
gameInfo
.
set_started
(
true
);
static_cast
<
GameScene
*>
(
gameView
->
scene
())
->
rearrange
();
gameView
->
show
();
phasesToolbar
->
show
();
}
void
TabGame
::
stopGame
()
...
...
@@ -888,7 +885,6 @@ void TabGame::stopGame()
playerListWidget
->
setGameStarted
(
false
,
false
);
gameInfo
.
set_started
(
false
);
gameView
->
hide
();
phasesToolbar
->
hide
();
}
void
TabGame
::
closeGame
()
...
...
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