From a2757308248544a80da27a2cbb9965fa76141aa6 Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 5 Aug 2016 18:37:35 -0700 Subject: [PATCH] gtk: fix crash when hit rematch button Not all games have a draw context. Check! --- xwords4/linux/gamesdb.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xwords4/linux/gamesdb.c b/xwords4/linux/gamesdb.c index a50b35f03..cbabf1ee6 100644 --- a/xwords4/linux/gamesdb.c +++ b/xwords4/linux/gamesdb.c @@ -176,16 +176,20 @@ addSnap( CommonGlobals* cGlobals ) BoardCtxt* board = cGlobals->game.board; GtkDrawCtx* dctx = (GtkDrawCtx*)board_getDraw( board ); - addSurface( dctx, SNAP_WIDTH, SNAP_HEIGHT ); - board_drawSnapshot( board, (DrawCtx*)dctx, SNAP_WIDTH, SNAP_HEIGHT ); + if ( !!dctx ) { + addSurface( dctx, SNAP_WIDTH, SNAP_HEIGHT ); + board_drawSnapshot( board, (DrawCtx*)dctx, SNAP_WIDTH, SNAP_HEIGHT ); - XWStreamCtxt* stream = make_simple_stream( cGlobals ); - getImage( dctx, stream ); - removeSurface( dctx ); - sqlite3_int64 newRow = writeBlobColumnStream( stream, cGlobals->pDb, - cGlobals->selRow, "snap" ); - XP_ASSERT( cGlobals->selRow == newRow ); - stream_destroy( stream ); + XWStreamCtxt* stream = make_simple_stream( cGlobals ); + getImage( dctx, stream ); + removeSurface( dctx ); + sqlite3_int64 newRow = writeBlobColumnStream( stream, cGlobals->pDb, + cGlobals->selRow, "snap" ); + XP_ASSERT( cGlobals->selRow == newRow ); + stream_destroy( stream ); + } + + LOG_RETURN_VOID(); } void