fix crash loading new game before snapshot exists

This commit is contained in:
Eric House 2016-08-05 10:37:42 -07:00
parent 0c6283ea63
commit 7f513313b0
3 changed files with 15 additions and 17 deletions

View file

@ -24,8 +24,8 @@
#include "linuxutl.h" #include "linuxutl.h"
#include "main.h" #include "main.h"
#define SNAP_WIDTH 200 #define SNAP_WIDTH 150
#define SNAP_HEIGHT 200 #define SNAP_HEIGHT 150
static void getColumnText( sqlite3_stmt *ppStmt, int iCol, XP_UCHAR* buf, static void getColumnText( sqlite3_stmt *ppStmt, int iCol, XP_UCHAR* buf,
int len ); int len );
@ -322,21 +322,16 @@ getGameInfo( sqlite3* pDb, sqlite3_int64 rowid, GameInfo* gib )
snprintf( gib->name, sizeof(gib->name), "Game %lld", rowid ); snprintf( gib->name, sizeof(gib->name), "Game %lld", rowid );
/* Load the snapshot */ /* Load the snapshot */
GdkPixbuf* snap = NULL;
const XP_U8* ptr = sqlite3_column_blob( ppStmt, 10 ); const XP_U8* ptr = sqlite3_column_blob( ppStmt, 10 );
int size = sqlite3_column_bytes( ppStmt, 10 ); if ( !!ptr ) {
/* Skip the version that's written in */ int size = sqlite3_column_bytes( ppStmt, 10 );
ptr += sizeof(XP_U16); size -= sizeof(XP_U16); /* Skip the version that's written in */
GInputStream* istr = g_memory_input_stream_new_from_data( ptr, size, NULL ); ptr += sizeof(XP_U16); size -= sizeof(XP_U16);
GError *error = NULL; GInputStream* istr = g_memory_input_stream_new_from_data( ptr, size, NULL );
GdkPixbuf* snap = gdk_pixbuf_new_from_stream( istr, NULL, &error ); snap = gdk_pixbuf_new_from_stream( istr, NULL, NULL );
g_object_unref( istr ); g_object_unref( istr );
if ( !snap ) {
XP_LOGF( "%s(): error from gdk_pixbuf_new_from_stream(): %s",
__func__, error->message );
g_error_free( error );
} }
XP_ASSERT( !!snap );
gib->snap = snap; gib->snap = snap;
} }
sqlite3_finalize( ppStmt ); sqlite3_finalize( ppStmt );

View file

@ -93,8 +93,11 @@ initCairo( GtkDrawCtx* dctx )
XP_Bool inited = !!cairo; XP_Bool inited = !!cairo;
if ( inited ) { if ( inited ) {
dctx->_cairo = cairo; dctx->_cairo = cairo;
/* XP_LOGF( "dctx->cairo=%p", dctx->_cairo ); */ if ( !!dctx->surface ) {
cairo_set_line_width( cairo, 1.0 ); cairo_set_line_width( cairo, 0.1 );
} else {
cairo_set_line_width( cairo, 1.0 );
}
cairo_set_line_cap( cairo, CAIRO_LINE_CAP_SQUARE ); cairo_set_line_cap( cairo, CAIRO_LINE_CAP_SQUARE );
} }
return inited; return inited;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B