Revision: 1509
          http://geeqie.svn.sourceforge.net/geeqie/?rev=1509&view=rev
Author:   zas_
Date:     2009-03-11 17:38:20 +0000 (Wed, 11 Mar 2009)

Log Message:
-----------
Use dynamic allocation for editor key passed to various callbacks.

Modified Paths:
--------------
    trunk/src/bar_sort.c
    trunk/src/menu.c
    trunk/src/view_dir.c

Modified: trunk/src/bar_sort.c
===================================================================
--- trunk/src/bar_sort.c        2009-03-10 22:52:12 UTC (rev 1508)
+++ trunk/src/bar_sort.c        2009-03-11 17:38:20 UTC (rev 1509)
@@ -66,7 +66,7 @@
 
        SortModeType mode;
        SortActionType action;
-       const gchar *filter_key;
+       gchar *filter_key;
        
        SortSelectionType selection;
 
@@ -355,7 +355,7 @@
        if (action == BAR_SORT_FILTER)
                {
                if (!filter_key) filter_key = "";
-               sd->filter_key = filter_key;
+               sd->filter_key = g_strdup(filter_key);
                }
        else
                {
@@ -546,11 +546,17 @@
 
        bar_sort_add_close(sd);
 
+       g_free(sd->filter_key);
        g_free(sd->undo_src);
        g_free(sd->undo_dest);
        g_free(sd);
 }
 
+static void bar_sort_edit_button_free(gpointer data)
+{
+       g_free(data);
+}
+
 static GtkWidget *bar_sort_new(LayoutWindow *lw, SortActionType action, 
SortModeType mode, SortSelectionType selection, const gchar *filter_key)
 {
        SortData *sd;
@@ -615,24 +621,26 @@
                {
                GtkWidget *button;
                EditorDescription *editor = work->data;
+               gchar *key;
+               gboolean select = FALSE;
+
                work = work->next;
-               gboolean select = FALSE;
+                       
+               if (!editor_is_filter(editor->key)) continue;
                
-               if (!editor_is_filter(editor->key)) continue;
-
-               if (sd->action == BAR_SORT_FILTER && strcmp(editor->key, 
filter_key) == 0)
+               key = g_strdup(editor->key);
+               if (sd->action == BAR_SORT_FILTER && strcmp(key, filter_key) == 
0)
                        {
-                       bar_sort_set_action(sd, sd->action, editor->key);
+                       bar_sort_set_action(sd, sd->action, key);
                        select = TRUE;
                        have_filter = TRUE;
                        }
-
+               
                button = pref_radiobutton_new(sd->folder_group, buttongrp,
                                              editor->name, select,
                                              
G_CALLBACK(bar_sort_set_filter_cb), sd);
 
-
-               g_object_set_data(G_OBJECT(button), "filter_key", editor->key);
+               g_object_set_data_full(G_OBJECT(button), "filter_key", key, 
bar_sort_edit_button_free);
                }
        g_list_free(editors_list);
        

Modified: trunk/src/menu.c
===================================================================
--- trunk/src/menu.c    2009-03-10 22:52:12 UTC (rev 1508)
+++ trunk/src/menu.c    2009-03-11 17:38:20 UTC (rev 1509)
@@ -64,6 +64,10 @@
  * edit menu
  *-----------------------------------------------------------------------------
  */
+static void edit_item_destroy_cb(GtkWidget *widget, gpointer data)
+{
+       g_free(data);
+}
 
 static void add_edit_items(GtkWidget *menu, GCallback func, GList *fd_list)
 {
@@ -81,11 +85,15 @@
 
                if (active)
                        {
+                       GtkWidget *item;
                        const gchar *stock_id = NULL;
-                       if (editor->icon && 
register_theme_icon_as_stock(editor->key, editor->icon))
-                               stock_id = editor->key;
+                       gchar *key = g_strdup(editor->key);
 
-                       menu_item_add_stock(menu, editor->name, stock_id, func, 
editor->key);
+                       if (editor->icon && register_theme_icon_as_stock(key, 
editor->icon))
+                               stock_id = key;
+
+                       item = menu_item_add_stock(menu, editor->name, 
stock_id, func, key);
+                       g_signal_connect(G_OBJECT(item), "destroy", 
G_CALLBACK(edit_item_destroy_cb), key);
                        }
                }
        

Modified: trunk/src/view_dir.c
===================================================================
--- trunk/src/view_dir.c        2009-03-10 22:52:12 UTC (rev 1508)
+++ trunk/src/view_dir.c        2009-03-11 17:38:20 UTC (rev 1509)
@@ -330,8 +330,11 @@
        file_util_start_filter_from_filelist(key, list, path, vd->widget);
 }
 
+static void vd_drop_menu_edit_item_free(gpointer data)
+{
+       g_free(data);
+}
 
-
 GtkWidget *vd_drop_menu(ViewDir *vd, gint active)
 {
        GtkWidget *menu;
@@ -350,12 +353,13 @@
                {
                GtkWidget *item;
                const EditorDescription *editor = work->data;
+               gchar *key;
                work = work->next;
                
                if (!editor_is_filter(editor->key)) continue;
+               key = g_strdup(editor->key);
                item = menu_item_add_sensitive(menu, editor->name, active, 
G_CALLBACK(vd_drop_menu_filter_cb), vd);
-
-               g_object_set_data(G_OBJECT(item), "filter_key", editor->key);
+               g_object_set_data_full(G_OBJECT(item), "filter_key", key, 
vd_drop_menu_edit_item_free);
                }
        
        g_list_free(editors_list);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn

Reply via email to