mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
fix crash drawing game timer
It's outside the normal begin_/end_draw flow and so cairo wasn't set up as expected.
This commit is contained in:
parent
592a6429d4
commit
618ee89add
1 changed files with 18 additions and 7 deletions
|
@ -112,6 +112,12 @@ destroyCairo( GtkDrawCtx* dctx )
|
|||
dctx->_cairo = NULL;
|
||||
}
|
||||
|
||||
static XP_Bool
|
||||
haveCairo( const GtkDrawCtx* dctx )
|
||||
{
|
||||
return !!dctx->_cairo;
|
||||
}
|
||||
|
||||
static cairo_t*
|
||||
getCairo( const GtkDrawCtx* dctx )
|
||||
{
|
||||
|
@ -1231,15 +1237,20 @@ gtk_draw_drawTimer( DrawCtx* p_dctx, const XP_Rect* rInner,
|
|||
XP_U16 playerNum, XP_S16 secondsLeft )
|
||||
{
|
||||
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
|
||||
XP_UCHAR buf[10];
|
||||
XP_Bool hadCairo = haveCairo( dctx );
|
||||
if ( hadCairo || initCairo( dctx ) ) {
|
||||
XP_UCHAR buf[10];
|
||||
|
||||
gtkFormatTimerText( buf, VSIZE(buf), secondsLeft );
|
||||
gtkFormatTimerText( buf, VSIZE(buf), secondsLeft );
|
||||
|
||||
/* gdk_gc_set_clip_rectangle( dctx->drawGC, (GdkRectangle*)rInner ); */
|
||||
gtkEraseRect( dctx, rInner );
|
||||
draw_string_at( dctx, NULL, buf, rInner->height-1,
|
||||
rInner, XP_GTK_JUST_CENTER,
|
||||
&dctx->playerColors[playerNum], NULL );
|
||||
gtkEraseRect( dctx, rInner );
|
||||
draw_string_at( dctx, NULL, buf, rInner->height-1,
|
||||
rInner, XP_GTK_JUST_CENTER,
|
||||
&dctx->playerColors[playerNum], NULL );
|
||||
if ( !hadCairo ) {
|
||||
destroyCairo( dctx );
|
||||
}
|
||||
}
|
||||
} /* gtk_draw_drawTimer */
|
||||
|
||||
#ifdef XWFEATURE_MINIWIN
|
||||
|
|
Loading…
Reference in a new issue