Commit 85727947 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/units.c app/core/gimp-units.c app/core/gimp.c added a utility function

2005-01-13  Sven Neumann  <sven@gimp.org>

	* app/units.c
	* app/core/gimp-units.c
	* app/core/gimp.c
	* app/core/gimpunit.[ch]: added a utility function that frees the
	memory allocated for user units. Minor cleanups.
parent c743f6de
2005-01-13 Sven Neumann <sven@gimp.org>
* app/units.c
* app/core/gimp-units.c
* app/core/gimp.c
* app/core/gimpunit.[ch]: added a utility function that frees the
memory allocated for user units. Minor cleanups.
2005-01-13 Sven Neumann <sven@gimp.org>
* configure.in (ALL_LINGUAS): added mk (Macedonian).
......
......@@ -62,14 +62,7 @@ gimp_units_exit (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (gimp->user_units)
{
g_list_foreach (gimp->user_units, (GFunc) g_free, NULL);
g_list_free (gimp->user_units);
gimp->user_units = NULL;
gimp->n_user_units = 0;
}
gimp_user_units_free (gimp);
}
......@@ -273,7 +266,6 @@ gimp_unitrc_unit_info_deserialize (GScanner *scanner,
gchar *singular = NULL;
gchar *plural = NULL;
GTokenType token;
GimpUnit unit;
if (! gimp_scanner_parse_string (scanner, &identifier))
return G_TOKEN_STRING;
......@@ -350,8 +342,10 @@ gimp_unitrc_unit_info_deserialize (GScanner *scanner,
if (g_scanner_peek_next_token (scanner) == token)
{
unit = _gimp_unit_new (gimp, identifier, factor, digits,
symbol, abbreviation, singular, plural);
GimpUnit unit = _gimp_unit_new (gimp,
identifier, factor, digits,
symbol, abbreviation,
singular, plural);
/* make the unit definition persistent */
_gimp_unit_set_deletion_flag (gimp, unit, FALSE);
......
......@@ -457,8 +457,7 @@ gimp_finalize (GObject *object)
gimp->session_name = NULL;
}
if (gimp->user_units)
gimp_units_exit (gimp);
gimp_units_exit (gimp);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......
......@@ -258,3 +258,30 @@ _gimp_unit_get_plural (Gimp *gimp,
return gettext (_gimp_unit_get_user_unit (gimp, unit)->plural);
}
/* The sole purpose of this function is to release the allocated
* memory. It must only be used from gimp_units_exit().
*/
void
gimp_user_units_free (Gimp *gimp)
{
GList *list;
for (list = gimp->user_units; list; list = g_list_next (list))
{
GimpUnitDef *user_unit = list->data;
g_free (user_unit->identifier);
g_free (user_unit->symbol);
g_free (user_unit->abbreviation);
g_free (user_unit->singular);
g_free (user_unit->plural);
g_free (user_unit);
}
g_list_free (gimp->user_units);
gimp->user_units = NULL;
gimp->n_user_units = 0;
}
......@@ -56,5 +56,7 @@ const gchar * _gimp_unit_get_singular (Gimp *gimp,
const gchar * _gimp_unit_get_plural (Gimp *gimp,
GimpUnit unit);
void gimp_user_units_free (Gimp *gimp);
#endif /* __APP_GIMP_UNIT_H__ */
......@@ -73,7 +73,7 @@ units_unit_get_deletion_flag (GimpUnit unit)
static void
units_unit_set_deletion_flag (GimpUnit unit,
gboolean deletion_flag)
gboolean deletion_flag)
{
_gimp_unit_set_deletion_flag (the_unit_gimp, unit, deletion_flag);
}
......@@ -132,16 +132,16 @@ units_init (Gimp *gimp)
vtable.unit_get_number_of_units = units_get_number_of_units;
vtable.unit_get_number_of_built_in_units = units_get_number_of_built_in_units;
vtable.unit_new = units_unit_new;
vtable.unit_get_deletion_flag = units_unit_get_deletion_flag;
vtable.unit_set_deletion_flag = units_unit_set_deletion_flag;
vtable.unit_get_factor = units_unit_get_factor;
vtable.unit_get_digits = units_unit_get_digits;
vtable.unit_get_identifier = units_unit_get_identifier;
vtable.unit_get_symbol = units_unit_get_symbol;
vtable.unit_get_abbreviation = units_unit_get_abbreviation;
vtable.unit_get_singular = units_unit_get_singular;
vtable.unit_get_plural = units_unit_get_plural;
vtable.unit_new = units_unit_new;
vtable.unit_get_deletion_flag = units_unit_get_deletion_flag;
vtable.unit_set_deletion_flag = units_unit_set_deletion_flag;
vtable.unit_get_factor = units_unit_get_factor;
vtable.unit_get_digits = units_unit_get_digits;
vtable.unit_get_identifier = units_unit_get_identifier;
vtable.unit_get_symbol = units_unit_get_symbol;
vtable.unit_get_abbreviation = units_unit_get_abbreviation;
vtable.unit_get_singular = units_unit_get_singular;
vtable.unit_get_plural = units_unit_get_plural;
gimp_base_init (&vtable);
}
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