mirror of https://github.com/GNOME/gimp.git
modules/cdisplay_lcms.c corrected memory handling. cmsOpenProfileFromMem()
2007-08-08 Sven Neumann <sven@gimp.org> * modules/cdisplay_lcms.c * plug-ins/common/lcms.c: corrected memory handling. cmsOpenProfileFromMem() actually copies the data. * libgimpwidgets/gimpcolordisplay.c * libgimpwidgets/gimpcolordisplaystack.c: disconnect in dispose(). svn path=/trunk/; revision=23148
This commit is contained in:
parent
40144a272b
commit
4ab3e92782
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,12 @@
|
|||
2007-08-08 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* modules/cdisplay_lcms.c
|
||||
* plug-ins/common/lcms.c: corrected memory handling.
|
||||
cmsOpenProfileFromMem() actually copies the data.
|
||||
|
||||
* libgimpwidgets/gimpcolordisplay.c
|
||||
* libgimpwidgets/gimpcolordisplaystack.c: disconnect in dispose().
|
||||
|
||||
2007-08-08 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/jpeg/jpeg-save.c (save_dialog): added missing call to
|
||||
|
@ -5,7 +14,8 @@
|
|||
|
||||
* plug-ins/jpeg/jpeg-load.c
|
||||
* plug-ins/jpeg/jpeg-save.c
|
||||
* plug-ins/jpeg/jpeg.[ch]: renamed global variables.
|
||||
* plug-ins/jpeg/jpeg.[ch]: renamed global variables used for the
|
||||
preview hack.
|
||||
|
||||
2007-08-08 Sven Neumann <sven@gimp.org>
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ typedef struct
|
|||
static GObject * gimp_color_display_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_color_display_finalize (GObject *object);
|
||||
static void gimp_color_display_dispose (GObject *object);
|
||||
static void gimp_color_display_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
|
@ -93,7 +93,7 @@ gimp_color_display_class_init (GimpColorDisplayClass *klass)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_color_display_constructor;
|
||||
object_class->finalize = gimp_color_display_finalize;
|
||||
object_class->dispose = gimp_color_display_dispose;
|
||||
object_class->set_property = gimp_color_display_set_property;
|
||||
object_class->get_property = gimp_color_display_get_property;
|
||||
|
||||
|
@ -160,7 +160,7 @@ gimp_color_display_constructor (GType type,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_color_display_finalize (GObject *object)
|
||||
gimp_color_display_dispose (GObject *object)
|
||||
{
|
||||
GimpColorDisplayPrivate *private = GIMP_COLOR_DISPLAY_GET_PRIVATE (object);
|
||||
|
||||
|
@ -182,7 +182,7 @@ gimp_color_display_finalize (GObject *object)
|
|||
private->managed = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -43,13 +43,15 @@ enum
|
|||
};
|
||||
|
||||
|
||||
static void gimp_color_display_stack_finalize (GObject *object);
|
||||
static void gimp_color_display_stack_dispose (GObject *object);
|
||||
|
||||
static void gimp_color_display_stack_display_changed (GimpColorDisplay *display,
|
||||
GimpColorDisplayStack *stack);
|
||||
static void gimp_color_display_stack_display_enabled (GimpColorDisplay *display,
|
||||
GParamSpec *pspec,
|
||||
GimpColorDisplayStack *stack);
|
||||
static void gimp_color_display_stack_disconnect (GimpColorDisplayStack *stack,
|
||||
GimpColorDisplay *display);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpColorDisplayStack, gimp_color_display_stack, G_TYPE_OBJECT)
|
||||
|
@ -105,7 +107,7 @@ gimp_color_display_stack_class_init (GimpColorDisplayStackClass *klass)
|
|||
GIMP_TYPE_COLOR_DISPLAY,
|
||||
G_TYPE_INT);
|
||||
|
||||
object_class->finalize = gimp_color_display_stack_finalize;
|
||||
object_class->dispose = gimp_color_display_stack_dispose;
|
||||
|
||||
klass->changed = NULL;
|
||||
klass->added = NULL;
|
||||
|
@ -120,18 +122,27 @@ gimp_color_display_stack_init (GimpColorDisplayStack *stack)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_color_display_stack_finalize (GObject *object)
|
||||
gimp_color_display_stack_dispose (GObject *object)
|
||||
{
|
||||
GimpColorDisplayStack *stack = GIMP_COLOR_DISPLAY_STACK (object);
|
||||
|
||||
if (stack->filters)
|
||||
{
|
||||
g_list_foreach (stack->filters, (GFunc) g_object_unref, NULL);
|
||||
GList *list;
|
||||
|
||||
for (list = stack->filters; list; list = g_list_next (list))
|
||||
{
|
||||
GimpColorDisplay *display = list->data;
|
||||
|
||||
gimp_color_display_stack_disconnect (stack, display);
|
||||
g_object_unref (display);
|
||||
}
|
||||
|
||||
g_list_free (stack->filters);
|
||||
stack->filters = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
GimpColorDisplayStack *
|
||||
|
@ -181,12 +192,12 @@ gimp_color_display_stack_add (GimpColorDisplayStack *stack,
|
|||
|
||||
stack->filters = g_list_append (stack->filters, g_object_ref (display));
|
||||
|
||||
g_signal_connect_object (display, "changed",
|
||||
g_signal_connect (display, "changed",
|
||||
G_CALLBACK (gimp_color_display_stack_display_changed),
|
||||
G_OBJECT (stack), 0);
|
||||
g_signal_connect_object (display, "notify::enabled",
|
||||
G_OBJECT (stack));
|
||||
g_signal_connect (display, "notify::enabled",
|
||||
G_CALLBACK (gimp_color_display_stack_display_enabled),
|
||||
G_OBJECT (stack), 0);
|
||||
G_OBJECT (stack));
|
||||
|
||||
g_signal_emit (stack, stack_signals[ADDED], 0,
|
||||
display, g_list_length (stack->filters) - 1);
|
||||
|
@ -202,12 +213,7 @@ gimp_color_display_stack_remove (GimpColorDisplayStack *stack,
|
|||
g_return_if_fail (GIMP_IS_COLOR_DISPLAY (display));
|
||||
g_return_if_fail (g_list_find (stack->filters, display) != NULL);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (display,
|
||||
gimp_color_display_stack_display_changed,
|
||||
stack);
|
||||
g_signal_handlers_disconnect_by_func (display,
|
||||
gimp_color_display_stack_display_enabled,
|
||||
stack);
|
||||
gimp_color_display_stack_disconnect (stack, display);
|
||||
|
||||
stack->filters = g_list_remove (stack->filters, display);
|
||||
|
||||
|
@ -306,3 +312,15 @@ gimp_color_display_stack_display_enabled (GimpColorDisplay *display,
|
|||
{
|
||||
gimp_color_display_stack_changed (stack);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_display_stack_disconnect (GimpColorDisplayStack *stack,
|
||||
GimpColorDisplay *display)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (display,
|
||||
gimp_color_display_stack_display_changed,
|
||||
stack);
|
||||
g_signal_handlers_disconnect_by_func (display,
|
||||
gimp_color_display_stack_display_enabled,
|
||||
stack);
|
||||
}
|
||||
|
|
|
@ -440,8 +440,6 @@ cdisplay_lcms_get_display_profile (CdisplayLcms *lcms)
|
|||
&type, &format, &nitems, &data) && nitems > 0)
|
||||
{
|
||||
profile = cmsOpenProfileFromMem (data, nitems);
|
||||
|
||||
/* FIXME: check memory mamagement of cmsOpenProfileFromMem */
|
||||
g_free (data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -685,7 +685,7 @@ lcms_image_get_profile (GimpColorConfig *config,
|
|||
profile = cmsOpenProfileFromMem ((gpointer) gimp_parasite_data (parasite),
|
||||
gimp_parasite_data_size (parasite));
|
||||
|
||||
/* FIXME: we leak the parasite, the data is used by the profile */
|
||||
gimp_parasite_free (parasite);
|
||||
|
||||
if (profile)
|
||||
{
|
||||
|
@ -695,8 +695,6 @@ lcms_image_get_profile (GimpColorConfig *config,
|
|||
}
|
||||
else
|
||||
{
|
||||
gimp_parasite_free (parasite);
|
||||
|
||||
g_message (_("Data attached as 'icc-profile' does not appear to "
|
||||
"be an ICC color profile"));
|
||||
}
|
||||
|
@ -930,28 +928,23 @@ lcms_load_profile (const gchar *filename,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
data = g_mapped_file_get_contents (file);
|
||||
len = g_mapped_file_get_length (file);
|
||||
|
||||
data = g_memdup (g_mapped_file_get_contents (file), len);
|
||||
|
||||
g_mapped_file_free (file);
|
||||
|
||||
profile = cmsOpenProfileFromMem (data, len);
|
||||
|
||||
/* FIXME: we leak the data, it is used by the profile */
|
||||
|
||||
if (profile)
|
||||
{
|
||||
lcms_calculate_checksum (data, len, checksum);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (data);
|
||||
|
||||
g_message (_("Could not load ICC profile from '%s'"),
|
||||
gimp_filename_to_utf8 (filename));
|
||||
}
|
||||
|
||||
g_mapped_file_free (file);
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue