gimp r25723 - in trunk: . app/core



Author: mitch
Date: Tue May 20 21:30:40 2008
New Revision: 25723
URL: http://svn.gnome.org/viewvc/gimp?rev=25723&view=rev

Log:
2008-05-20  Michael Natterer  <mitch gimp org>

	* app/core/gimplist.c (gimp_list_uniquefy_name): don't crash if an
	object has a NULL name. Move variables to local scopes. Remove
	redundant casts.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimplist.c

Modified: trunk/app/core/gimplist.c
==============================================================================
--- trunk/app/core/gimplist.c	(original)
+++ trunk/app/core/gimplist.c	Tue May 20 21:30:40 2008
@@ -487,24 +487,25 @@
 gimp_list_uniquefy_name (GimpList   *gimp_list,
                          GimpObject *object)
 {
-  GList *list;
-  GList *list2;
-  gint   unique_ext = 0;
-  gchar *new_name   = NULL;
-  gchar *ext;
+  GList       *list;
+  const gchar *name = gimp_object_get_name (object);
 
-  g_return_if_fail (GIMP_IS_LIST (gimp_list));
-  g_return_if_fail (GIMP_IS_OBJECT (object));
+  if (! name)
+    return;
 
   for (list = gimp_list->list; list; list = g_list_next (list))
     {
-      GimpObject *object2 = GIMP_OBJECT (list->data);
+      GimpObject  *object2 = list->data;
+      const gchar *name2   = gimp_object_get_name (object2);
 
       if (object != object2 &&
-          strcmp (gimp_object_get_name (GIMP_OBJECT (object)),
-                  gimp_object_get_name (GIMP_OBJECT (object2))) == 0)
+          name2             &&
+          ! strcmp (name, name2))
         {
-          ext = strrchr (object->name, '#');
+          GList *list2;
+          gchar *ext        = strrchr (name, '#');
+          gchar *new_name   = NULL;
+          gint   unique_ext = 0;
 
           if (ext)
             {
@@ -526,10 +527,6 @@
 
               g_free (ext_str);
             }
-          else
-            {
-              unique_ext = 0;
-            }
 
           do
             {
@@ -537,16 +534,16 @@
 
               g_free (new_name);
 
-              new_name = g_strdup_printf ("%s#%d", object->name, unique_ext);
+              new_name = g_strdup_printf ("%s#%d", name, unique_ext);
 
               for (list2 = gimp_list->list; list2; list2 = g_list_next (list2))
                 {
-                  object2 = GIMP_OBJECT (list2->data);
-
-                  if (object == object2)
-                    continue;
+                  object2 = list2->data;
+                  name2   = gimp_object_get_name (object2);
 
-                  if (! strcmp (object2->name, new_name))
+                  if (object != object2 &&
+                      name2             &&
+                      ! strcmp (new_name, name2))
                     break;
                 }
             }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]