From b171e57502060d683fe591e3ae70c904a686812e Mon Sep 17 00:00:00 2001 From: Eric Wertz Date: Fri, 24 Feb 2017 16:33:03 -0500 Subject: [PATCH] Fixing segfaults --- Makefile | 2 +- dock_icon.c | 21 ++++++++++++--------- main.c | 2 +- pager_item.c | 7 +++++++ 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 23065cb..77ec352 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -Wall -lm -lX11 `pkg-config --cflags gtk+-3.0 libwnck-3.0` +CFLAGS = -g -Wall -lm -lX11 `pkg-config --cflags gtk+-3.0 libwnck-3.0` LDFLAGS = `pkg-config --libs gtk+-3.0 libwnck-3.0` DEPS = dock_icon.h ericdock.h clock.h drawing.h eric_window.h pager_item.h tooltip_window.h OBJ = dock_icon.o tooltip_window.o eric_window.o clock.o main.o pager_item.o drawing.o diff --git a/dock_icon.c b/dock_icon.c index ab5bf70..84634c6 100644 --- a/dock_icon.c +++ b/dock_icon.c @@ -151,16 +151,19 @@ GdkPixbuf* get_icon( WnckWindow* window, guint size ) printf( "class: %s\ninstance%s\n", class_name, instance_name ); - int i; - for( i = 0; class_name[i] && i < 256; i++ ) - class_lower[i] = tolower( class_name[i] ); - for( i = 0; instance_name[i] && i < 256; i++ ) - instance_lower[i] = tolower( instance_name[i] ); - - //Use the window's icon - if( strcmp( class_lower, instance_lower ) != 0 ) + if( class_name != NULL && instance_name != NULL ) { - pixbuf = wnck_window_get_icon( window ); + int i; + for( i = 0; class_name[i] && i < 256; i++ ) + class_lower[i] = tolower( class_name[i] ); + for( i = 0; instance_name[i] && i < 256; i++ ) + instance_lower[i] = tolower( instance_name[i] ); + + //Use the window's icon + if( strcmp( class_lower, instance_lower ) != 0 ) + { + pixbuf = wnck_window_get_icon( window ); + } } //Check for desktop file entry diff --git a/main.c b/main.c index 78a442a..6c47a44 100644 --- a/main.c +++ b/main.c @@ -40,7 +40,7 @@ void add_window_to_pager( WnckWindow* window ) for( icon_list = dock_icons; icon_list != NULL; icon_list = icon_list->next ) { icon = (dock_icon*)icon_list->data; - if( strcmp( icon->instance_name, instance_name ) == 0 ) + if( icon->instance_name != NULL && instance_name != NULL && strcmp( icon->instance_name, instance_name ) == 0 ) { icon->pager_items = g_list_append( icon->pager_items, pager_item_create( window ) ); found_class_group = 1; diff --git a/pager_item.c b/pager_item.c index 83afcd3..bc9dbf1 100644 --- a/pager_item.c +++ b/pager_item.c @@ -76,6 +76,13 @@ 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 ) ) + { + item->icon_pixbuf = get_icon( item->window, (int)SCALE_VALUE( 16.0 ) ); + if( !GDK_IS_PIXBUF( item->icon_pixbuf ) ) + return; + } + if( item->icon_state == ICON_STATE_HOVER ) { w->text_color.alpha = 0.25; -- 2.47.0