]> Eric's Git Repo - ericdock.git/commitdiff
Fixing segfaults
authorEric Wertz <ericdwertz@gmail.com>
Fri, 24 Feb 2017 21:33:03 +0000 (16:33 -0500)
committerEric Wertz <ericdwertz@gmail.com>
Fri, 24 Feb 2017 21:33:03 +0000 (16:33 -0500)
Makefile
dock_icon.c
main.c
pager_item.c

index 23065cbb5bf33a11cc2417324d5c9e1ec2bad909..77ec352ffe833b9b3207e14b695312ddcca80241 100644 (file)
--- 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
index ab5bf70274bd0d683464d6c334833d709141e3d8..84634c666fc92083a12c5543c6732a6d4a59f385 100644 (file)
@@ -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 78a442af8679f77d10bfda245151b8bbf097a375..6c47a44175d572dc45631a681e384515f0ee814b 100644 (file)
--- 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;
index 83afcd363ee6347960b27691408973d62e19b3ac..bc9dbf122cdcf6f1751770c5efb20244cb4fbe9c 100644 (file)
@@ -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;