Commit e7c969dd authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

uniquefy pattern names before inserting them into the list. This way DND

2000-12-19  Michael Natterer  <mitch@gimp.org>

	* app/patterns.c: uniquefy pattern names before inserting them
	into the list. This way DND (which passes only the pattern's
	name) works as expected. Fixes #35258.
parent 3c85607e
2000-12-19 Michael Natterer <mitch@gimp.org>
* app/patterns.c: uniquefy pattern names before inserting them
into the list. This way DND (which passes only the pattern's
name) works as expected. Fixes #35258.
2000-12-19 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
......
......@@ -57,6 +57,7 @@ GPattern *active_pattern = NULL;
GSList *pattern_list = NULL;
gint num_patterns = 0;
/* static variables */
static GPattern *standard_pattern = NULL;
......@@ -283,6 +284,11 @@ load_pattern (gchar *filename)
{
GPattern *pattern;
gint fd;
GSList *list;
GSList *list2;
gint unique_ext = 0;
gchar *ext;
gchar *new_name = NULL;
g_return_if_fail (filename != NULL);
......@@ -301,6 +307,64 @@ load_pattern (gchar *filename)
if (stingy_memory_use)
temp_buf_swap (pattern->mask);
/* uniquefy pattern name */
for (list = pattern_list; list; list = g_slist_next (list))
{
if (! strcmp (((GPattern *) list->data)->name, pattern->name))
{
ext = strrchr (pattern->name, '#');
if (ext)
{
gchar *ext_str;
unique_ext = atoi (ext + 1);
ext_str = g_strdup_printf ("%d", unique_ext);
/* check if the extension really is of the form "#<n>" */
if (! strcmp (ext_str, ext + 1))
{
*ext = '\0';
}
else
{
unique_ext = 0;
}
g_free (ext_str);
}
else
{
unique_ext = 0;
}
do
{
unique_ext++;
g_free (new_name);
new_name = g_strdup_printf ("%s#%d", pattern->name, unique_ext);
for (list2 = pattern_list; list2; list2 = g_slist_next (list2))
{
if (! strcmp (((GPattern *) list2->data)->name, new_name))
{
break;
}
}
}
while (list2);
g_free (pattern->name);
pattern->name = new_name;
break;
}
}
pattern_list = g_slist_insert_sorted (pattern_list, pattern,
pattern_compare_func);
}
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