Commit 1420685b authored by Tor Lillqvist's avatar Tor Lillqvist
Browse files

Fix adding of numbers after drawable copies. We used to get pairs of

* app/gimpdrawable.c (gimp_drawable_set_name): Fix adding of
  numbers after drawable copies. We used to get pairs of duplicates
  after adding the same name several times.

(Try by adding a new layer several times in the layers dialog. You will
get New Layer, New Layer#2, New Layer#3, New Layer#3 (again!), New Layer#4,
New Layer#4 (again!), etc.)
parent ab5ee157
Tue Feb 02 20:58:40 1999 Tor Lillqvist <tml@iki.fi>
* app/gimpdrawable.c (gimp_drawable_set_name): Fix adding of
numbers after drawable copies. We used to get pairs of duplicates
after adding the same name several times.
1999-01-31 Jay Cox <jaycox@earthlink.net>
* app/color_balance.c: optimized by using a lookup table
......
......@@ -312,6 +312,7 @@ gimp_drawable_set_name (GimpDrawable *drawable, char *name)
int number = 1;
char *newname;
char *ext;
char numberbuf[20];
g_return_if_fail(GIMP_IS_DRAWABLE(drawable));
if (drawable->name)
......@@ -343,8 +344,11 @@ gimp_drawable_set_name (GimpDrawable *drawable, char *name)
if ((ext = strrchr(newname, '#')))
{
number = atoi(ext+1);
if (&ext[(int)(log10(number) + 1)] != &newname[strlen(newname) - 1])
/* Check if there really was the number we think after the # */
sprintf (numberbuf, "#%d", number);
if (strcmp (ext, numberbuf) != 0)
{
/* No, so just ignore the # */
number = 1;
ext = &newname[strlen(newname)];
}
......@@ -364,7 +368,9 @@ gimp_drawable_set_name (GimpDrawable *drawable, char *name)
{
number++;
sprintf(ext, "#%d", number+1);
/* Rescan from beginning */
listb = base_list;
continue;
}
listb = listb->next;
}
......
......@@ -312,6 +312,7 @@ gimp_drawable_set_name (GimpDrawable *drawable, char *name)
int number = 1;
char *newname;
char *ext;
char numberbuf[20];
g_return_if_fail(GIMP_IS_DRAWABLE(drawable));
if (drawable->name)
......@@ -343,8 +344,11 @@ gimp_drawable_set_name (GimpDrawable *drawable, char *name)
if ((ext = strrchr(newname, '#')))
{
number = atoi(ext+1);
if (&ext[(int)(log10(number) + 1)] != &newname[strlen(newname) - 1])
/* Check if there really was the number we think after the # */
sprintf (numberbuf, "#%d", number);
if (strcmp (ext, numberbuf) != 0)
{
/* No, so just ignore the # */
number = 1;
ext = &newname[strlen(newname)];
}
......@@ -364,7 +368,9 @@ gimp_drawable_set_name (GimpDrawable *drawable, char *name)
{
number++;
sprintf(ext, "#%d", number+1);
/* Rescan from beginning */
listb = base_list;
continue;
}
listb = listb->next;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment