From ca75974b605899bd714d547a5d87592b2f72cb28 Mon Sep 17 00:00:00 2001 From: Eric Wertz Date: Sun, 25 Jun 2017 00:14:07 -0400 Subject: [PATCH] Trying to get rid of missing icon crash --- dock_icon.c | 3 +-- main.c | 4 +++- pager_item.c | 13 +++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dock_icon.c b/dock_icon.c index 84634c6..5edc248 100644 --- a/dock_icon.c +++ b/dock_icon.c @@ -18,7 +18,6 @@ dock_icon* dock_icon_create( WnckWindow* window ) icon->class_group = wnck_window_get_class_group( window ); icon->instance_name = wnck_window_get_class_instance_name( window ); icon->icon_pixbuf = get_icon( window, (int)SCALE_VALUE( 32.0 ) ); - g_object_ref( icon->icon_pixbuf ); icon->pager_items = NULL; icon->icon_state = ICON_STATE_NORMAL; @@ -196,7 +195,7 @@ GdkPixbuf* get_icon( WnckWindow* window, guint size ) g_free(stripped); - return pixbuf; + return gdk_pixbuf_copy( pixbuf ); } /* From matchbox-desktop */ diff --git a/main.c b/main.c index 884bef2..f8b08f8 100644 --- a/main.c +++ b/main.c @@ -165,7 +165,9 @@ static gboolean draw_dock_window( GtkWidget* widget, cairo_t* cr, eric_window* w cairo_fill( cr ); } if( !GDK_IS_PIXBUF( icon->icon_pixbuf ) ) - icon->icon_pixbuf = wnck_class_group_get_icon( icon->class_group ); + { + icon->icon_pixbuf = gdk_pixbuf_copy( wnck_class_group_get_icon( icon->class_group ) ); + } gdk_cairo_set_source_pixbuf( cr, icon->icon_pixbuf, x+SCALE_VALUE( 4.0 ), y ); cairo_paint( cr ); diff --git a/pager_item.c b/pager_item.c index bc9dbf1..ac30af9 100644 --- a/pager_item.c +++ b/pager_item.c @@ -19,11 +19,15 @@ void pager_item_name_changed( WnckWindow* window, pager_item* item ) void pager_item_icon_changed( WnckWindow* window, pager_item* item ) { - if( GDK_IS_PIXBUF( item->icon_pixbuf ) ) + if( item->icon_pixbuf && GDK_IS_PIXBUF( item->icon_pixbuf ) ) + { g_object_unref( item->icon_pixbuf ); + item->icon_pixbuf = NULL; + } + printf( "Icon changed %s\n", item->name ); item->icon_pixbuf = get_icon( window, (int)SCALE_VALUE( 16.0 ) ); - g_object_ref( item->icon_pixbuf ); + gtk_widget_queue_draw( dock_window->window ); } void pager_item_state_changed( WnckWindow* window, WnckWindowState changed_mask, WnckWindowState new_state, pager_item* item ) @@ -36,8 +40,9 @@ pager_item* pager_item_create( WnckWindow* window ) pager_item* item = malloc( sizeof( pager_item ) ); item->window = window; strcpy( item->name, wnck_window_get_name( item->window ) ); + item->icon_pixbuf = get_icon( window, (int)SCALE_VALUE( 16.0 ) ); - g_object_ref( item->icon_pixbuf ); + item->icon_state = ICON_STATE_NORMAL; g_signal_connect( G_OBJECT( window ), "name-changed", G_CALLBACK( pager_item_name_changed ), (gpointer)item ); @@ -76,7 +81,7 @@ int pager_item_mouse_move( pager_item* item, double mx, double my ) void pager_item_draw( pager_item* item, cairo_t* cr, eric_window* w, cairo_pattern_t* pattern ) { - if( !GDK_IS_PIXBUF( item->icon_pixbuf ) ) + if( item->icon_pixbuf && !GDK_IS_PIXBUF( item->icon_pixbuf ) ) { item->icon_pixbuf = get_icon( item->window, (int)SCALE_VALUE( 16.0 ) ); if( !GDK_IS_PIXBUF( item->icon_pixbuf ) ) -- 2.47.0