Changeset 172 for gtkimageview/src

Show
Ignore:
Timestamp:
06/13/07 00:10:40 (6 years ago)
Author:
bjourne
Message:

Fix a really obvious memory leak. One more remains and has something to do with GdkCursors.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gtkimageview/src/gtkimagetoolselector.c

    r171 r172  
    265265    image_view_drawer_free (selector->bg_drawer); 
    266266    image_view_drawer_free (selector->fg_drawer); 
    267     g_hash_table_unref (selector->cursors); 
     267 
     268    GdkCursorType types[] = {GDK_CROSSHAIR, GDK_FLEUR}; 
     269    for (int n = 0; n < G_N_ELEMENTS (types); n++) 
     270    { 
     271        GdkCursor *cursor = g_hash_table_lookup (selector->cursors, 
     272                                                 (int *) types[n]); 
     273        gdk_cursor_unref (cursor); 
     274    } 
     275    g_hash_table_destroy (selector->cursors); 
    268276    g_free (selector->mouse_handler); 
    269277    /* Chain up */ 
     
    288296    tool->fg_drawer = image_view_drawer_new (); 
    289297 
    290     GdkDisplay *display = gdk_display_get_default(); 
    291  
    292298    tool->cursors = g_hash_table_new (NULL, NULL); 
    293299    GdkCursorType types[] = {GDK_CROSSHAIR, GDK_FLEUR}; 
    294300    for (int n = 0; n < G_N_ELEMENTS (types); n++) 
    295301    { 
    296         GdkCursor *cursor = gdk_cursor_new_for_display (display, types[n]); 
     302        GdkCursor *cursor = gdk_cursor_new (types[n]); 
    297303        g_hash_table_insert (tool->cursors, (int *) types[n], cursor); 
    298304    }