added missing g_rand_free().
2003-08-27 Michael Natterer <mitch@gimp.org> * app/composite/gimp-composite-generic.c (gimp_composite_generic_init): added missing g_rand_free(). * app/widgets/gimpitemfactory.[ch]: fixed all leaks in gimp_item_factory_translate_func(). Added item_factory->translation_trash for the pathological cases. Free the trash after each call to gtk_item_factory_create_item().
This commit is contained in:

committed by
Michael Natterer

parent
0eff267590
commit
1ce3055058
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2003-08-27 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
* app/composite/gimp-composite-generic.c
|
||||||
|
(gimp_composite_generic_init): added missing g_rand_free().
|
||||||
|
|
||||||
|
* app/widgets/gimpitemfactory.[ch]: fixed all leaks in
|
||||||
|
gimp_item_factory_translate_func(). Added
|
||||||
|
item_factory->translation_trash for the pathological cases. Free
|
||||||
|
the trash after each call to gtk_item_factory_create_item().
|
||||||
|
|
||||||
2003-08-27 Sven Neumann <sven@gimp.org>
|
2003-08-27 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* plug-ins/common/edge.c: applied patch from Guillermo S. Romero
|
* plug-ins/common/edge.c: applied patch from Guillermo S. Romero
|
||||||
|
@ -1133,15 +1133,18 @@ gimp_composite_scale_any_any_any_generic (GimpCompositeContext * ctx)
|
|||||||
void
|
void
|
||||||
gimp_composite_generic_init (void)
|
gimp_composite_generic_init (void)
|
||||||
{
|
{
|
||||||
guint i;
|
|
||||||
GRand *gr;
|
GRand *gr;
|
||||||
|
guint i;
|
||||||
|
|
||||||
#define RANDOM_SEED 314159265
|
#define RANDOM_SEED 314159265
|
||||||
|
|
||||||
/* generate a table of random seeds */
|
/* generate a table of random seeds */
|
||||||
gr = g_rand_new_with_seed(RANDOM_SEED);
|
gr = g_rand_new_with_seed (RANDOM_SEED);
|
||||||
|
|
||||||
for (i = 0; i < RANDOM_TABLE_SIZE; i++)
|
for (i = 0; i < RANDOM_TABLE_SIZE; i++)
|
||||||
random_table[i] = g_rand_int(gr);
|
random_table[i] = g_rand_int (gr);
|
||||||
|
|
||||||
|
g_rand_free (gr);
|
||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
add_lut[i] = i;
|
add_lut[i] = i;
|
||||||
|
@ -114,10 +114,11 @@ gimp_item_factory_class_init (GimpItemFactoryClass *klass)
|
|||||||
static void
|
static void
|
||||||
gimp_item_factory_init (GimpItemFactory *factory)
|
gimp_item_factory_init (GimpItemFactory *factory)
|
||||||
{
|
{
|
||||||
factory->gimp = NULL;
|
factory->gimp = NULL;
|
||||||
factory->update_func = NULL;
|
factory->update_func = NULL;
|
||||||
factory->update_on_popup = FALSE;
|
factory->update_on_popup = FALSE;
|
||||||
factory->help_id = NULL;
|
factory->help_id = NULL;
|
||||||
|
factory->translation_trash = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -331,6 +332,13 @@ gimp_item_factory_create_item (GimpItemFactory *item_factory,
|
|||||||
if (textdomain)
|
if (textdomain)
|
||||||
g_object_set_data (G_OBJECT (item_factory), "textdomain", NULL);
|
g_object_set_data (G_OBJECT (item_factory), "textdomain", NULL);
|
||||||
|
|
||||||
|
if (item_factory->translation_trash)
|
||||||
|
{
|
||||||
|
g_list_foreach (item_factory->translation_trash, (GFunc) g_free, NULL);
|
||||||
|
g_list_free (item_factory->translation_trash);
|
||||||
|
item_factory->translation_trash = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
menu_path = gimp_strip_uline (((GtkItemFactoryEntry *) entry)->path);
|
menu_path = gimp_strip_uline (((GtkItemFactoryEntry *) entry)->path);
|
||||||
|
|
||||||
menu_item = gtk_item_factory_get_item (GTK_ITEM_FACTORY (item_factory),
|
menu_item = gtk_item_factory_get_item (GTK_ITEM_FACTORY (item_factory),
|
||||||
@ -970,27 +978,32 @@ static gchar *
|
|||||||
gimp_item_factory_translate_func (const gchar *path,
|
gimp_item_factory_translate_func (const gchar *path,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkItemFactory *item_factory;
|
GtkItemFactory *item_factory;
|
||||||
gchar *menupath;
|
GimpItemFactory *gimp_factory;
|
||||||
gchar *retval;
|
const gchar *retval;
|
||||||
gchar *translation;
|
gchar *translation;
|
||||||
gchar *domain = NULL;
|
gchar *domain = NULL;
|
||||||
gchar *complete = NULL;
|
gchar *complete = NULL;
|
||||||
gchar *p, *t;
|
gchar *p, *t;
|
||||||
|
|
||||||
item_factory = GTK_ITEM_FACTORY (data);
|
item_factory = GTK_ITEM_FACTORY (data);
|
||||||
|
gimp_factory = GIMP_ITEM_FACTORY (data);
|
||||||
|
|
||||||
if (strstr (path, "tearoff") ||
|
if (strstr (path, "tearoff") ||
|
||||||
strstr (path, "/---") ||
|
strstr (path, "/---") ||
|
||||||
strstr (path, "/MRU"))
|
strstr (path, "/MRU"))
|
||||||
return g_strdup (path);
|
{
|
||||||
|
return (gchar *) path;
|
||||||
|
}
|
||||||
|
|
||||||
domain = g_object_get_data (G_OBJECT (item_factory), "textdomain");
|
domain = g_object_get_data (G_OBJECT (item_factory), "textdomain");
|
||||||
complete = g_object_get_data (G_OBJECT (item_factory), "complete");
|
complete = g_object_get_data (G_OBJECT (item_factory), "complete");
|
||||||
|
|
||||||
if (domain) /* use the plugin textdomain */
|
if (domain) /* use the plugin textdomain */
|
||||||
{
|
{
|
||||||
menupath = g_strconcat (item_factory->path, path, NULL);
|
gchar *full_path;
|
||||||
|
|
||||||
|
full_path = g_strconcat (item_factory->path, path, NULL);
|
||||||
|
|
||||||
if (complete)
|
if (complete)
|
||||||
{
|
{
|
||||||
@ -1000,7 +1013,12 @@ gimp_item_factory_translate_func (const gchar *path,
|
|||||||
complete = g_strconcat (item_factory->path, complete, NULL);
|
complete = g_strconcat (item_factory->path, complete, NULL);
|
||||||
translation = g_strdup (dgettext (domain, complete));
|
translation = g_strdup (dgettext (domain, complete));
|
||||||
|
|
||||||
while (*complete && *translation && strcmp (complete, menupath))
|
g_print ("moving plug-in translation to trash: %s\n", translation);
|
||||||
|
|
||||||
|
gimp_factory->translation_trash =
|
||||||
|
g_list_prepend (gimp_factory->translation_trash, translation);
|
||||||
|
|
||||||
|
while (*complete && *translation && strcmp (complete, full_path))
|
||||||
{
|
{
|
||||||
p = strrchr (complete, '/');
|
p = strrchr (complete, '/');
|
||||||
t = strrchr (translation, '/');
|
t = strrchr (translation, '/');
|
||||||
@ -1014,15 +1032,13 @@ gimp_item_factory_translate_func (const gchar *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_free (complete);
|
g_free (complete);
|
||||||
|
/* DON'T set complete to NULL here */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
translation = dgettext (domain, menupath);
|
translation = dgettext (domain, full_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
|
|
||||||
*/
|
|
||||||
if (strncmp (item_factory->path, translation,
|
if (strncmp (item_factory->path, translation,
|
||||||
strlen (item_factory->path)) == 0)
|
strlen (item_factory->path)) == 0)
|
||||||
{
|
{
|
||||||
@ -1031,17 +1047,15 @@ gimp_item_factory_translate_func (const gchar *path,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_warning ("%s: bad translation for menupath: %s",
|
g_warning ("%s: bad translation for menupath: %s",
|
||||||
G_STRLOC, menupath);
|
G_STRLOC, full_path);
|
||||||
|
|
||||||
retval = menupath + strlen (item_factory->path);
|
retval = path;
|
||||||
if (complete)
|
|
||||||
g_free (translation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (full_path);
|
||||||
}
|
}
|
||||||
else /* use the gimp textdomain */
|
else /* use the gimp textdomain */
|
||||||
{
|
{
|
||||||
menupath = retval = g_strdup (path);
|
|
||||||
|
|
||||||
if (complete)
|
if (complete)
|
||||||
{
|
{
|
||||||
/* This is a branch, use the complete path for translation,
|
/* This is a branch, use the complete path for translation,
|
||||||
@ -1050,7 +1064,12 @@ gimp_item_factory_translate_func (const gchar *path,
|
|||||||
complete = g_strdup (complete);
|
complete = g_strdup (complete);
|
||||||
translation = g_strdup (gettext (complete));
|
translation = g_strdup (gettext (complete));
|
||||||
|
|
||||||
while (*complete && *translation && strcmp (complete, menupath))
|
g_print ("moving core translation to trash: %s\n", translation);
|
||||||
|
|
||||||
|
gimp_factory->translation_trash =
|
||||||
|
g_list_prepend (gimp_factory->translation_trash, translation);
|
||||||
|
|
||||||
|
while (*complete && *translation && strcmp (complete, path))
|
||||||
{
|
{
|
||||||
p = strrchr (complete, '/');
|
p = strrchr (complete, '/');
|
||||||
t = strrchr (translation, '/');
|
t = strrchr (translation, '/');
|
||||||
@ -1064,9 +1083,12 @@ gimp_item_factory_translate_func (const gchar *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_free (complete);
|
g_free (complete);
|
||||||
|
/* DON'T set complete to NULL here */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
translation = gettext (menupath);
|
{
|
||||||
|
translation = gettext (path);
|
||||||
|
}
|
||||||
|
|
||||||
if (*translation == '/')
|
if (*translation == '/')
|
||||||
{
|
{
|
||||||
@ -1075,12 +1097,11 @@ gimp_item_factory_translate_func (const gchar *path,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_warning ("%s: bad translation for menupath: %s",
|
g_warning ("%s: bad translation for menupath: %s",
|
||||||
G_STRLOC, menupath);
|
G_STRLOC, path);
|
||||||
|
|
||||||
if (complete)
|
retval = path;
|
||||||
g_free (translation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return (gchar *) retval;
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ struct _GimpItemFactory
|
|||||||
GimpItemFactoryUpdateFunc update_func;
|
GimpItemFactoryUpdateFunc update_func;
|
||||||
gboolean update_on_popup;
|
gboolean update_on_popup;
|
||||||
gchar *help_id;
|
gchar *help_id;
|
||||||
|
|
||||||
|
GList *translation_trash;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpItemFactoryClass
|
struct _GimpItemFactoryClass
|
||||||
|
Reference in New Issue
Block a user