From 71fb14bce1c9e72e98b70815637a2f878449caf4 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 27 Jan 2019 08:46:51 -0800 Subject: [PATCH] fix gtk critical errors --- xwords4/linux/gtkdraw.c | 18 ++++++++++++++---- xwords4/linux/gtkmain.c | 14 +++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/xwords4/linux/gtkdraw.c b/xwords4/linux/gtkdraw.c index c2491466e..b222dbd92 100644 --- a/xwords4/linux/gtkdraw.c +++ b/xwords4/linux/gtkdraw.c @@ -85,6 +85,8 @@ initCairo( GtkDrawCtx* dctx ) if ( !!dctx->surface ) { cairo = cairo_create( dctx->surface ); + cairo_surface_destroy( dctx->surface ); + // XP_ASSERT( 0 ); } else if ( !!dctx->drawing_area ) { #ifdef GDK_AVAILABLE_IN_3_22 GdkWindow* window = gtk_widget_get_window( dctx->drawing_area ); @@ -115,12 +117,16 @@ destroyCairo( GtkDrawCtx* dctx ) { /* XP_LOGF( "%s(dctx=%p)", __func__, dctx ); */ XP_ASSERT( !!dctx->_cairo ); + if ( !!dctx->surface ) { + XP_LOGF( "%s(): have surface; doing nothing", __func__ ); + } else { #ifdef GDK_AVAILABLE_IN_3_22 - GdkWindow* window = gtk_widget_get_window( dctx->drawing_area ); - gdk_window_end_draw_frame( window, dctx->dc ); + GdkWindow* window = gtk_widget_get_window( dctx->drawing_area ); + gdk_window_end_draw_frame( window, dctx->dc ); #else - cairo_destroy( dctx->_cairo ); + cairo_destroy( dctx->_cairo ); #endif + } dctx->_cairo = NULL; } @@ -464,6 +470,8 @@ gtk_draw_beginDraw( DrawCtx* p_dctx ) #ifdef USE_CAIRO GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; return initCairo( dctx ); +#else + fix this #endif } @@ -1509,7 +1517,7 @@ void removeSurface( GtkDrawCtx* dctx ) { XP_ASSERT( !!dctx->surface ); - g_object_unref( dctx->surface ); + cairo_surface_destroy( dctx->surface ); dctx->surface = NULL; } @@ -1534,6 +1542,8 @@ getImage( GtkDrawCtx* XP_UNUSED_DBG(dctx), XWStreamCtxt* XP_UNUSED_DBG(stream) ) cairo_surface_write_to_png_stream( dctx->surface, write_func, stream ); XP_ASSERT( CAIRO_STATUS_SUCCESS == status ); +#else + error Will Robinson #endif } diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index 24ee899d3..4f5a5b8b2 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -216,20 +216,24 @@ add_to_list( GtkWidget* list, sqlite3_int64 rowid, XP_Bool isNew, GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(list)); GtkListStore* store = GTK_LIST_STORE( model ); GtkTreeIter iter; - if ( isNew ) { - gtk_list_store_append( store, &iter ); - } else { - gboolean valid; - for ( valid = gtk_tree_model_get_iter_first( model, &iter ); + XP_Bool found = XP_FALSE; + if ( !isNew ) { + for ( gboolean valid = gtk_tree_model_get_iter_first( model, &iter ); valid; valid = gtk_tree_model_iter_next( model, &iter ) ) { sqlite3_int64 tmpid; gtk_tree_model_get( model, &iter, ROW_ITEM, &tmpid, -1 ); if ( tmpid == rowid ) { + found = XP_TRUE; break; } } } + + if ( !found ) { + gtk_list_store_append( store, &iter ); + } + gchar* localString = 0 <= gib->turn ? gib->turnLocal ? "YES" : "NO" : "";