mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-18 13:53:46 +00:00
Use g_set_object() in a lot of places, and splrinkle some g_clear_object()
This commit is contained in:
parent
23ea457751
commit
1b7d63cce9
|
@ -932,17 +932,10 @@ gimp_set_clipboard_image (Gimp *gimp,
|
|||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
|
||||
|
||||
/* ref first, it could be the same as gimp->clipboard_image, but
|
||||
* don't bail if equal because always we want the signal emission
|
||||
*/
|
||||
if (image)
|
||||
g_object_ref (image);
|
||||
|
||||
g_clear_object (&gimp->clipboard_buffer);
|
||||
g_clear_object (&gimp->clipboard_image);
|
||||
|
||||
gimp->clipboard_image = image;
|
||||
g_set_object (&gimp->clipboard_image, image);
|
||||
|
||||
/* we want the signal emission */
|
||||
g_signal_emit (gimp, gimp_signals[CLIPBOARD_CHANGED], 0);
|
||||
}
|
||||
|
||||
|
@ -961,15 +954,10 @@ gimp_set_clipboard_buffer (Gimp *gimp,
|
|||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (buffer == NULL || GIMP_IS_BUFFER (buffer));
|
||||
|
||||
/* see above */
|
||||
if (buffer)
|
||||
g_object_ref (buffer);
|
||||
|
||||
g_clear_object (&gimp->clipboard_image);
|
||||
g_clear_object (&gimp->clipboard_buffer);
|
||||
|
||||
gimp->clipboard_buffer = buffer;
|
||||
g_set_object (&gimp->clipboard_buffer, buffer);
|
||||
|
||||
/* we want the signal emission */
|
||||
g_signal_emit (gimp, gimp_signals[CLIPBOARD_CHANGED], 0);
|
||||
}
|
||||
|
||||
|
@ -1022,16 +1010,7 @@ gimp_set_default_context (Gimp *gimp,
|
|||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
|
||||
|
||||
if (context != gimp->default_context)
|
||||
{
|
||||
if (gimp->default_context)
|
||||
g_object_unref (gimp->default_context);
|
||||
|
||||
gimp->default_context = context;
|
||||
|
||||
if (gimp->default_context)
|
||||
g_object_ref (gimp->default_context);
|
||||
}
|
||||
g_set_object (&gimp->default_context, context);
|
||||
}
|
||||
|
||||
GimpContext *
|
||||
|
@ -1049,16 +1028,7 @@ gimp_set_user_context (Gimp *gimp,
|
|||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
|
||||
|
||||
if (context != gimp->user_context)
|
||||
{
|
||||
if (gimp->user_context)
|
||||
g_object_unref (gimp->user_context);
|
||||
|
||||
gimp->user_context = context;
|
||||
|
||||
if (gimp->user_context)
|
||||
g_object_ref (gimp->user_context);
|
||||
}
|
||||
g_set_object (&gimp->user_context, context);
|
||||
}
|
||||
|
||||
GimpContext *
|
||||
|
|
|
@ -2123,19 +2123,14 @@ gimp_context_real_set_tool (GimpContext *context,
|
|||
|
||||
/* disconnect from the old tool's signals */
|
||||
if (context->tool_info)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->tool_info,
|
||||
gimp_context_tool_dirty,
|
||||
context);
|
||||
g_object_unref (context->tool_info);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->tool_info,
|
||||
gimp_context_tool_dirty,
|
||||
context);
|
||||
|
||||
context->tool_info = tool_info;
|
||||
g_set_object (&context->tool_info, tool_info);
|
||||
|
||||
if (tool_info)
|
||||
{
|
||||
g_object_ref (tool_info);
|
||||
|
||||
g_signal_connect_object (tool_info, "name-changed",
|
||||
G_CALLBACK (gimp_context_tool_dirty),
|
||||
context,
|
||||
|
@ -2250,19 +2245,14 @@ gimp_context_real_set_paint_info (GimpContext *context,
|
|||
|
||||
/* disconnect from the old paint info's signals */
|
||||
if (context->paint_info)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->paint_info,
|
||||
gimp_context_paint_info_dirty,
|
||||
context);
|
||||
g_object_unref (context->paint_info);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->paint_info,
|
||||
gimp_context_paint_info_dirty,
|
||||
context);
|
||||
|
||||
context->paint_info = paint_info;
|
||||
g_set_object (&context->paint_info, paint_info);
|
||||
|
||||
if (paint_info)
|
||||
{
|
||||
g_object_ref (paint_info);
|
||||
|
||||
g_signal_connect_object (paint_info, "name-changed",
|
||||
G_CALLBACK (gimp_context_paint_info_dirty),
|
||||
context,
|
||||
|
@ -2608,19 +2598,14 @@ gimp_context_real_set_brush (GimpContext *context,
|
|||
|
||||
/* disconnect from the old brush's signals */
|
||||
if (context->brush)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->brush,
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
g_object_unref (context->brush);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->brush,
|
||||
gimp_context_brush_dirty,
|
||||
context);
|
||||
|
||||
context->brush = brush;
|
||||
g_set_object (&context->brush, brush);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
g_object_ref (brush);
|
||||
|
||||
g_signal_connect_object (brush, "name-changed",
|
||||
G_CALLBACK (gimp_context_brush_dirty),
|
||||
context,
|
||||
|
@ -2729,19 +2714,14 @@ gimp_context_real_set_dynamics (GimpContext *context,
|
|||
|
||||
/* disconnect from the old dynamics' signals */
|
||||
if (context->dynamics)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->dynamics,
|
||||
gimp_context_dynamics_dirty,
|
||||
context);
|
||||
g_object_unref (context->dynamics);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->dynamics,
|
||||
gimp_context_dynamics_dirty,
|
||||
context);
|
||||
|
||||
context->dynamics = dynamics;
|
||||
g_set_object (&context->dynamics, dynamics);
|
||||
|
||||
if (dynamics)
|
||||
{
|
||||
g_object_ref (dynamics);
|
||||
|
||||
g_signal_connect_object (dynamics, "name-changed",
|
||||
G_CALLBACK (gimp_context_dynamics_dirty),
|
||||
context,
|
||||
|
@ -2853,19 +2833,14 @@ gimp_context_real_set_mybrush (GimpContext *context,
|
|||
|
||||
/* disconnect from the old mybrush's signals */
|
||||
if (context->mybrush)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->mybrush,
|
||||
gimp_context_mybrush_dirty,
|
||||
context);
|
||||
g_object_unref (context->mybrush);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->mybrush,
|
||||
gimp_context_mybrush_dirty,
|
||||
context);
|
||||
|
||||
context->mybrush = brush;
|
||||
g_set_object (&context->mybrush, brush);
|
||||
|
||||
if (brush)
|
||||
{
|
||||
g_object_ref (brush);
|
||||
|
||||
g_signal_connect_object (brush, "name-changed",
|
||||
G_CALLBACK (gimp_context_mybrush_dirty),
|
||||
context,
|
||||
|
@ -2976,19 +2951,14 @@ gimp_context_real_set_pattern (GimpContext *context,
|
|||
|
||||
/* disconnect from the old pattern's signals */
|
||||
if (context->pattern)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->pattern,
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
g_object_unref (context->pattern);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->pattern,
|
||||
gimp_context_pattern_dirty,
|
||||
context);
|
||||
|
||||
context->pattern = pattern;
|
||||
g_set_object (&context->pattern, pattern);
|
||||
|
||||
if (pattern)
|
||||
{
|
||||
g_object_ref (pattern);
|
||||
|
||||
g_signal_connect_object (pattern, "name-changed",
|
||||
G_CALLBACK (gimp_context_pattern_dirty),
|
||||
context,
|
||||
|
@ -3099,19 +3069,14 @@ gimp_context_real_set_gradient (GimpContext *context,
|
|||
|
||||
/* disconnect from the old gradient's signals */
|
||||
if (context->gradient)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->gradient,
|
||||
gimp_context_gradient_dirty,
|
||||
context);
|
||||
g_object_unref (context->gradient);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->gradient,
|
||||
gimp_context_gradient_dirty,
|
||||
context);
|
||||
|
||||
context->gradient = gradient;
|
||||
g_set_object (&context->gradient, gradient);
|
||||
|
||||
if (gradient)
|
||||
{
|
||||
g_object_ref (gradient);
|
||||
|
||||
g_signal_connect_object (gradient, "name-changed",
|
||||
G_CALLBACK (gimp_context_gradient_dirty),
|
||||
context,
|
||||
|
@ -3222,19 +3187,14 @@ gimp_context_real_set_palette (GimpContext *context,
|
|||
|
||||
/* disconnect from the old palette's signals */
|
||||
if (context->palette)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->palette,
|
||||
gimp_context_palette_dirty,
|
||||
context);
|
||||
g_object_unref (context->palette);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->palette,
|
||||
gimp_context_palette_dirty,
|
||||
context);
|
||||
|
||||
context->palette = palette;
|
||||
g_set_object (&context->palette, palette);
|
||||
|
||||
if (palette)
|
||||
{
|
||||
g_object_ref (palette);
|
||||
|
||||
g_signal_connect_object (palette, "name-changed",
|
||||
G_CALLBACK (gimp_context_palette_dirty),
|
||||
context,
|
||||
|
@ -3338,19 +3298,14 @@ gimp_context_real_set_tool_preset (GimpContext *context,
|
|||
|
||||
/* disconnect from the old tool preset's signals */
|
||||
if (context->tool_preset)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->tool_preset,
|
||||
gimp_context_tool_preset_dirty,
|
||||
context);
|
||||
g_object_unref (context->tool_preset);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->tool_preset,
|
||||
gimp_context_tool_preset_dirty,
|
||||
context);
|
||||
|
||||
context->tool_preset = tool_preset;
|
||||
g_set_object (&context->tool_preset, tool_preset);
|
||||
|
||||
if (tool_preset)
|
||||
{
|
||||
g_object_ref (tool_preset);
|
||||
|
||||
g_signal_connect_object (tool_preset, "name-changed",
|
||||
G_CALLBACK (gimp_context_tool_preset_dirty),
|
||||
context,
|
||||
|
@ -3494,19 +3449,14 @@ gimp_context_real_set_font (GimpContext *context,
|
|||
|
||||
/* disconnect from the old font's signals */
|
||||
if (context->font)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->font,
|
||||
gimp_context_font_dirty,
|
||||
context);
|
||||
g_object_unref (context->font);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->font,
|
||||
gimp_context_font_dirty,
|
||||
context);
|
||||
|
||||
context->font = font;
|
||||
g_set_object (&context->font, font);
|
||||
|
||||
if (font)
|
||||
{
|
||||
g_object_ref (font);
|
||||
|
||||
g_signal_connect_object (font, "name-changed",
|
||||
G_CALLBACK (gimp_context_font_dirty),
|
||||
context,
|
||||
|
@ -3621,19 +3571,14 @@ gimp_context_real_set_buffer (GimpContext *context,
|
|||
|
||||
/* disconnect from the old buffer's signals */
|
||||
if (context->buffer)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->buffer,
|
||||
gimp_context_buffer_dirty,
|
||||
context);
|
||||
g_object_unref (context->buffer);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->buffer,
|
||||
gimp_context_buffer_dirty,
|
||||
context);
|
||||
|
||||
context->buffer = buffer;
|
||||
g_set_object (&context->buffer, buffer);
|
||||
|
||||
if (buffer)
|
||||
{
|
||||
g_object_ref (buffer);
|
||||
|
||||
g_signal_connect_object (buffer, "name-changed",
|
||||
G_CALLBACK (gimp_context_buffer_dirty),
|
||||
context,
|
||||
|
@ -3747,19 +3692,14 @@ gimp_context_real_set_imagefile (GimpContext *context,
|
|||
|
||||
/* disconnect from the old imagefile's signals */
|
||||
if (context->imagefile)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->imagefile,
|
||||
gimp_context_imagefile_dirty,
|
||||
context);
|
||||
g_object_unref (context->imagefile);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->imagefile,
|
||||
gimp_context_imagefile_dirty,
|
||||
context);
|
||||
|
||||
context->imagefile = imagefile;
|
||||
g_set_object (&context->imagefile, imagefile);
|
||||
|
||||
if (imagefile)
|
||||
{
|
||||
g_object_ref (imagefile);
|
||||
|
||||
g_signal_connect_object (imagefile, "name-changed",
|
||||
G_CALLBACK (gimp_context_imagefile_dirty),
|
||||
context,
|
||||
|
@ -3873,19 +3813,14 @@ gimp_context_real_set_template (GimpContext *context,
|
|||
|
||||
/* disconnect from the old template's signals */
|
||||
if (context->template)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (context->template,
|
||||
gimp_context_template_dirty,
|
||||
context);
|
||||
g_object_unref (context->template);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (context->template,
|
||||
gimp_context_template_dirty,
|
||||
context);
|
||||
|
||||
context->template = template;
|
||||
g_set_object (&context->template, template);
|
||||
|
||||
if (template)
|
||||
{
|
||||
g_object_ref (template);
|
||||
|
||||
g_signal_connect_object (template, "name-changed",
|
||||
G_CALLBACK (gimp_context_template_dirty),
|
||||
context,
|
||||
|
|
|
@ -813,10 +813,8 @@ gimp_data_set_file (GimpData *data,
|
|||
if (private->internal)
|
||||
return;
|
||||
|
||||
if (private->file)
|
||||
g_object_unref (private->file);
|
||||
g_set_object (&private->file, file);
|
||||
|
||||
private->file = g_object_ref (file);
|
||||
private->writable = FALSE;
|
||||
private->deletable = FALSE;
|
||||
|
||||
|
|
|
@ -813,17 +813,10 @@ gimp_drawable_real_set_buffer (GimpDrawable *drawable,
|
|||
gimp_image_undo_push_drawable_mod (gimp_item_get_image (item), undo_desc,
|
||||
drawable, FALSE);
|
||||
|
||||
/* ref new before unrefing old, they might be the same */
|
||||
g_object_ref (buffer);
|
||||
|
||||
if (drawable->private->buffer)
|
||||
{
|
||||
old_has_alpha = gimp_drawable_has_alpha (drawable);
|
||||
old_has_alpha = gimp_drawable_has_alpha (drawable);
|
||||
|
||||
g_object_unref (drawable->private->buffer);
|
||||
}
|
||||
|
||||
drawable->private->buffer = buffer;
|
||||
g_set_object (&drawable->private->buffer, buffer);
|
||||
|
||||
if (drawable->private->buffer_source_node)
|
||||
gegl_node_set (drawable->private->buffer_source_node,
|
||||
|
|
|
@ -61,17 +61,12 @@ gimp_image_set_metadata (GimpImage *image,
|
|||
if (push_undo)
|
||||
gimp_image_undo_push_image_metadata (image, NULL);
|
||||
|
||||
if (private->metadata)
|
||||
g_object_unref (private->metadata);
|
||||
|
||||
private->metadata = metadata;
|
||||
g_set_object (&private->metadata, metadata);
|
||||
|
||||
if (private->metadata)
|
||||
{
|
||||
gdouble xres, yres;
|
||||
|
||||
g_object_ref (private->metadata);
|
||||
|
||||
gimp_metadata_set_pixel_size (metadata,
|
||||
gimp_image_get_width (image),
|
||||
gimp_image_get_height (image));
|
||||
|
|
|
@ -2118,16 +2118,8 @@ gimp_image_set_imported_file (GimpImage *image,
|
|||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
if (private->imported_file != file)
|
||||
if (g_set_object (&private->imported_file, file))
|
||||
{
|
||||
if (private->imported_file)
|
||||
g_object_unref (private->imported_file);
|
||||
|
||||
private->imported_file = file;
|
||||
|
||||
if (private->imported_file)
|
||||
g_object_ref (private->imported_file);
|
||||
|
||||
gimp_object_name_changed (GIMP_OBJECT (image));
|
||||
}
|
||||
}
|
||||
|
@ -2151,16 +2143,8 @@ gimp_image_set_exported_file (GimpImage *image,
|
|||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
if (private->exported_file != file)
|
||||
if (g_set_object (&private->exported_file, file))
|
||||
{
|
||||
if (private->exported_file)
|
||||
g_object_unref (private->exported_file);
|
||||
|
||||
private->exported_file = file;
|
||||
|
||||
if (private->exported_file)
|
||||
g_object_ref (private->exported_file);
|
||||
|
||||
gimp_object_name_changed (GIMP_OBJECT (image));
|
||||
}
|
||||
}
|
||||
|
@ -2184,16 +2168,7 @@ gimp_image_set_save_a_copy_file (GimpImage *image,
|
|||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
if (private->save_a_copy_file != file)
|
||||
{
|
||||
if (private->save_a_copy_file)
|
||||
g_object_unref (private->save_a_copy_file);
|
||||
|
||||
private->save_a_copy_file = file;
|
||||
|
||||
if (private->save_a_copy_file)
|
||||
g_object_ref (private->save_a_copy_file);
|
||||
}
|
||||
g_set_object (&private->save_a_copy_file, file);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
|
|
|
@ -2054,11 +2054,7 @@ gimp_item_set_parasites (GimpItem *item,
|
|||
|
||||
private = GET_PRIVATE (item);
|
||||
|
||||
if (parasites != private->parasites)
|
||||
{
|
||||
g_object_unref (private->parasites);
|
||||
private->parasites = g_object_ref (parasites);
|
||||
}
|
||||
g_set_object (&private->parasites, parasites);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2452,7 +2452,7 @@ gimp_layer_set_floating_sel_drawable (GimpLayer *layer,
|
|||
g_return_if_fail (GIMP_IS_LAYER (layer));
|
||||
g_return_if_fail (drawable == NULL || GIMP_IS_DRAWABLE (drawable));
|
||||
|
||||
if (layer->fs.drawable != drawable)
|
||||
if (g_set_object (&layer->fs.drawable, drawable))
|
||||
{
|
||||
if (layer->fs.segs)
|
||||
{
|
||||
|
@ -2461,14 +2461,6 @@ gimp_layer_set_floating_sel_drawable (GimpLayer *layer,
|
|||
layer->fs.num_segs = 0;
|
||||
}
|
||||
|
||||
if (layer->fs.drawable)
|
||||
g_object_unref (layer->fs.drawable);
|
||||
|
||||
layer->fs.drawable = drawable;
|
||||
|
||||
if (layer->fs.drawable)
|
||||
g_object_ref (layer->fs.drawable);
|
||||
|
||||
g_object_notify (G_OBJECT (layer), "floating-selection");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,16 +130,7 @@ gimp_paint_info_set_standard (Gimp *gimp,
|
|||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (! paint_info || GIMP_IS_PAINT_INFO (paint_info));
|
||||
|
||||
if (paint_info != gimp->standard_paint_info)
|
||||
{
|
||||
if (gimp->standard_paint_info)
|
||||
g_object_unref (gimp->standard_paint_info);
|
||||
|
||||
gimp->standard_paint_info = paint_info;
|
||||
|
||||
if (gimp->standard_paint_info)
|
||||
g_object_ref (gimp->standard_paint_info);
|
||||
}
|
||||
g_set_object (&gimp->standard_paint_info, paint_info);
|
||||
}
|
||||
|
||||
GimpPaintInfo *
|
||||
|
|
|
@ -272,16 +272,7 @@ gimp_tool_info_set_standard (Gimp *gimp,
|
|||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (! tool_info || GIMP_IS_TOOL_INFO (tool_info));
|
||||
|
||||
if (tool_info != gimp->standard_tool_info)
|
||||
{
|
||||
if (gimp->standard_tool_info)
|
||||
g_object_unref (gimp->standard_tool_info);
|
||||
|
||||
gimp->standard_tool_info = tool_info;
|
||||
|
||||
if (gimp->standard_tool_info)
|
||||
g_object_ref (gimp->standard_tool_info);
|
||||
}
|
||||
g_set_object (&gimp->standard_tool_info, tool_info);
|
||||
}
|
||||
|
||||
GimpToolInfo *
|
||||
|
|
|
@ -70,11 +70,7 @@ gimp_applicator_finalize (GObject *object)
|
|||
{
|
||||
GimpApplicator *applicator = GIMP_APPLICATOR (object);
|
||||
|
||||
if (applicator->node)
|
||||
{
|
||||
g_object_unref (applicator->node);
|
||||
applicator->node = NULL;
|
||||
}
|
||||
g_clear_object (&applicator->node);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
|
|
@ -878,14 +878,12 @@ gimp_brush_core_real_set_brush (GimpBrushCore *core,
|
|||
gimp_brush_core_invalidate_cache,
|
||||
core);
|
||||
gimp_brush_end_use (core->main_brush);
|
||||
g_clear_object (&core->main_brush);
|
||||
}
|
||||
|
||||
core->main_brush = brush;
|
||||
g_set_object (&core->main_brush, brush);
|
||||
|
||||
if (core->main_brush)
|
||||
{
|
||||
g_object_ref (core->main_brush);
|
||||
gimp_brush_begin_use (core->main_brush);
|
||||
g_signal_connect (core->main_brush, "invalidate-preview",
|
||||
G_CALLBACK (gimp_brush_core_invalidate_cache),
|
||||
|
@ -897,13 +895,7 @@ static void
|
|||
gimp_brush_core_real_set_dynamics (GimpBrushCore *core,
|
||||
GimpDynamics *dynamics)
|
||||
{
|
||||
if (dynamics == core->dynamics)
|
||||
return;
|
||||
|
||||
g_clear_object (&core->dynamics);
|
||||
|
||||
if (dynamics)
|
||||
core->dynamics = g_object_ref (dynamics);
|
||||
g_set_object (&core->dynamics, dynamics);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -184,11 +184,7 @@ gimp_color_tool_finalize (GObject *object)
|
|||
{
|
||||
GimpColorTool *color_tool = GIMP_COLOR_TOOL (object);
|
||||
|
||||
if (color_tool->options)
|
||||
{
|
||||
g_object_unref (color_tool->options);
|
||||
color_tool->options = NULL;
|
||||
}
|
||||
g_clear_object (&color_tool->options);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -642,10 +638,7 @@ gimp_color_tool_enable (GimpColorTool *color_tool,
|
|||
return;
|
||||
}
|
||||
|
||||
if (color_tool->options)
|
||||
g_object_unref (color_tool->options);
|
||||
|
||||
color_tool->options = g_object_ref (options);
|
||||
g_set_object (&color_tool->options, options);
|
||||
|
||||
/* color picking doesn't snap, see bug #768058 */
|
||||
color_tool->saved_snap_to = gimp_tool_control_get_snap_to (tool->control);
|
||||
|
@ -669,11 +662,7 @@ gimp_color_tool_disable (GimpColorTool *color_tool)
|
|||
return;
|
||||
}
|
||||
|
||||
if (color_tool->options)
|
||||
{
|
||||
g_object_unref (color_tool->options);
|
||||
color_tool->options = NULL;
|
||||
}
|
||||
g_clear_object (&color_tool->options);
|
||||
|
||||
gimp_tool_control_set_snap_to (tool->control, color_tool->saved_snap_to);
|
||||
color_tool->saved_snap_to = FALSE;
|
||||
|
|
|
@ -984,20 +984,15 @@ gimp_gradient_tool_set_gradient (GimpGradientTool *gradient_tool,
|
|||
GimpGradient *gradient)
|
||||
{
|
||||
if (gradient_tool->gradient)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (gradient_tool->gradient,
|
||||
G_CALLBACK (gimp_gradient_tool_gradient_dirty),
|
||||
gradient_tool);
|
||||
g_signal_handlers_disconnect_by_func (gradient_tool->gradient,
|
||||
G_CALLBACK (gimp_gradient_tool_gradient_dirty),
|
||||
gradient_tool);
|
||||
|
||||
g_object_unref (gradient_tool->gradient);
|
||||
}
|
||||
|
||||
gradient_tool->gradient = gradient;
|
||||
g_set_object (&gradient_tool->gradient, gradient);
|
||||
|
||||
if (gradient_tool->gradient)
|
||||
{
|
||||
g_object_ref (gradient);
|
||||
|
||||
g_signal_connect_swapped (gradient_tool->gradient, "dirty",
|
||||
G_CALLBACK (gimp_gradient_tool_gradient_dirty),
|
||||
gradient_tool);
|
||||
|
@ -1074,15 +1069,8 @@ gimp_gradient_tool_set_tentative_gradient (GimpGradientTool *gradient_tool,
|
|||
g_return_if_fail (GIMP_IS_GRADIENT_TOOL (gradient_tool));
|
||||
g_return_if_fail (gradient == NULL || GIMP_IS_GRADIENT (gradient));
|
||||
|
||||
if (gradient != gradient_tool->tentative_gradient)
|
||||
if (g_set_object (&gradient_tool->tentative_gradient, gradient))
|
||||
{
|
||||
g_clear_object (&gradient_tool->tentative_gradient);
|
||||
|
||||
gradient_tool->tentative_gradient = gradient;
|
||||
|
||||
if (gradient)
|
||||
g_object_ref (gradient);
|
||||
|
||||
if (gradient_tool->render_node)
|
||||
{
|
||||
gegl_node_set (gradient_tool->render_node,
|
||||
|
|
|
@ -638,11 +638,9 @@ tool_manager_select_tool (Gimp *gimp,
|
|||
tool_manager_control_active (gimp, GIMP_TOOL_ACTION_HALT, display);
|
||||
tool_manager_focus_display_active (gimp, NULL);
|
||||
}
|
||||
|
||||
g_object_unref (tool_manager->active_tool);
|
||||
}
|
||||
|
||||
tool_manager->active_tool = g_object_ref (tool);
|
||||
g_set_object (&tool_manager->active_tool, tool);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -465,22 +465,18 @@ gimp_container_view_real_set_context (GimpContainerView *view,
|
|||
{
|
||||
GimpContainerViewPrivate *private = GIMP_CONTAINER_VIEW_GET_PRIVATE (view);
|
||||
|
||||
if (private->context)
|
||||
if (private->context &&
|
||||
private->container)
|
||||
{
|
||||
if (private->container)
|
||||
gimp_container_view_disconnect_context (view);
|
||||
|
||||
g_object_unref (private->context);
|
||||
gimp_container_view_disconnect_context (view);
|
||||
}
|
||||
|
||||
private->context = context;
|
||||
g_set_object (&private->context, context);
|
||||
|
||||
if (private->context)
|
||||
if (private->context &&
|
||||
private->container)
|
||||
{
|
||||
g_object_ref (private->context);
|
||||
|
||||
if (private->container)
|
||||
gimp_container_view_connect_context (view);
|
||||
gimp_container_view_connect_context (view);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -327,24 +327,16 @@ gimp_pickable_button_set_pickable (GimpPickableButton *button,
|
|||
if (pickable != button->private->pickable)
|
||||
{
|
||||
if (button->private->pickable)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (button->private->pickable,
|
||||
gimp_pickable_button_notify_buffer,
|
||||
button);
|
||||
g_signal_handlers_disconnect_by_func (button->private->pickable,
|
||||
gimp_pickable_button_notify_buffer,
|
||||
button);
|
||||
|
||||
g_object_unref (button->private->pickable);
|
||||
}
|
||||
|
||||
button->private->pickable = pickable;
|
||||
g_set_object (&button->private->pickable, pickable);
|
||||
|
||||
if (button->private->pickable)
|
||||
{
|
||||
g_object_ref (button->private->pickable);
|
||||
|
||||
g_signal_connect (button->private->pickable, "notify::buffer",
|
||||
G_CALLBACK (gimp_pickable_button_notify_buffer),
|
||||
button);
|
||||
}
|
||||
g_signal_connect (button->private->pickable, "notify::buffer",
|
||||
G_CALLBACK (gimp_pickable_button_notify_buffer),
|
||||
button);
|
||||
|
||||
gimp_view_set_viewable (GIMP_VIEW (button->private->view),
|
||||
GIMP_VIEWABLE (pickable));
|
||||
|
|
|
@ -538,24 +538,16 @@ gimp_view_renderer_set_color_config (GimpViewRenderer *renderer,
|
|||
if (color_config != renderer->priv->color_config)
|
||||
{
|
||||
if (renderer->priv->color_config)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (renderer->priv->color_config,
|
||||
gimp_view_renderer_config_notify,
|
||||
renderer);
|
||||
g_signal_handlers_disconnect_by_func (renderer->priv->color_config,
|
||||
gimp_view_renderer_config_notify,
|
||||
renderer);
|
||||
|
||||
g_object_unref (renderer->priv->color_config);
|
||||
}
|
||||
|
||||
renderer->priv->color_config = color_config;
|
||||
g_set_object (&renderer->priv->color_config, color_config);
|
||||
|
||||
if (renderer->priv->color_config)
|
||||
{
|
||||
g_object_ref (renderer->priv->color_config);
|
||||
|
||||
g_signal_connect (renderer->priv->color_config, "notify",
|
||||
G_CALLBACK (gimp_view_renderer_config_notify),
|
||||
renderer);
|
||||
}
|
||||
g_signal_connect (renderer->priv->color_config, "notify",
|
||||
G_CALLBACK (gimp_view_renderer_config_notify),
|
||||
renderer);
|
||||
|
||||
gimp_view_renderer_config_notify (G_OBJECT (renderer->priv->color_config),
|
||||
NULL, renderer);
|
||||
|
@ -701,28 +693,20 @@ static void
|
|||
gimp_view_renderer_real_set_context (GimpViewRenderer *renderer,
|
||||
GimpContext *context)
|
||||
{
|
||||
if (renderer->context)
|
||||
if (renderer->context &&
|
||||
renderer->priv->color_config ==
|
||||
renderer->context->gimp->config->color_management)
|
||||
{
|
||||
if (renderer->priv->color_config ==
|
||||
renderer->context->gimp->config->color_management)
|
||||
{
|
||||
gimp_view_renderer_set_color_config (renderer, NULL);
|
||||
}
|
||||
|
||||
g_object_unref (renderer->context);
|
||||
gimp_view_renderer_set_color_config (renderer, NULL);
|
||||
}
|
||||
|
||||
renderer->context = context;
|
||||
g_set_object (&renderer->context, context);
|
||||
|
||||
if (renderer->context)
|
||||
if (renderer->context &&
|
||||
renderer->priv->color_config == NULL)
|
||||
{
|
||||
g_object_ref (renderer->context);
|
||||
|
||||
if (renderer->priv->color_config == NULL)
|
||||
{
|
||||
gimp_view_renderer_set_color_config (renderer,
|
||||
renderer->context->gimp->config->color_management);
|
||||
}
|
||||
gimp_view_renderer_set_color_config (renderer,
|
||||
renderer->context->gimp->config->color_management);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -967,19 +951,12 @@ gimp_view_renderer_render_pixbuf (GimpViewRenderer *renderer,
|
|||
dest += dest_stride;
|
||||
}
|
||||
|
||||
if (renderer->priv->pixbuf)
|
||||
g_object_unref (renderer->priv->pixbuf);
|
||||
|
||||
g_clear_object (&renderer->priv->pixbuf);
|
||||
renderer->priv->pixbuf = new;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_object_ref (pixbuf);
|
||||
|
||||
if (renderer->priv->pixbuf)
|
||||
g_object_unref (renderer->priv->pixbuf);
|
||||
|
||||
renderer->priv->pixbuf = pixbuf;
|
||||
g_set_object (&renderer->priv->pixbuf, pixbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -681,17 +681,14 @@ gimp_color_area_set_color_config (GimpColorArea *area,
|
|||
g_signal_handlers_disconnect_by_func (priv->config,
|
||||
gimp_color_area_destroy_transform,
|
||||
area);
|
||||
g_object_unref (priv->config);
|
||||
|
||||
gimp_color_area_destroy_transform (area);
|
||||
}
|
||||
|
||||
priv->config = config;
|
||||
g_set_object (&priv->config, config);
|
||||
|
||||
if (priv->config)
|
||||
{
|
||||
g_object_ref (priv->config);
|
||||
|
||||
g_signal_connect_swapped (priv->config, "notify",
|
||||
G_CALLBACK (gimp_color_area_destroy_transform),
|
||||
area);
|
||||
|
|
|
@ -895,16 +895,8 @@ gimp_color_button_set_color_config (GimpColorButton *button,
|
|||
|
||||
priv = GET_PRIVATE (button);
|
||||
|
||||
if (config != priv->config)
|
||||
if (g_set_object (&priv->config, config))
|
||||
{
|
||||
if (priv->config)
|
||||
g_object_unref (priv->config);
|
||||
|
||||
priv->config = config;
|
||||
|
||||
if (priv->config)
|
||||
g_object_ref (priv->config);
|
||||
|
||||
if (priv->color_area)
|
||||
gimp_color_area_set_color_config (GIMP_COLOR_AREA (priv->color_area),
|
||||
priv->config);
|
||||
|
|
|
@ -131,18 +131,11 @@ gimp_color_profile_view_set_profile (GimpColorProfileView *view,
|
|||
|
||||
gtk_text_buffer_set_text (buffer, "", 0);
|
||||
|
||||
if (view->priv->profile)
|
||||
g_object_unref (view->priv->profile);
|
||||
|
||||
view->priv->profile = profile;
|
||||
|
||||
if (view->priv->profile)
|
||||
if (g_set_object (&view->priv->profile, profile) && profile)
|
||||
{
|
||||
GtkTextIter iter;
|
||||
const gchar *text;
|
||||
|
||||
g_object_ref (view->priv->profile);
|
||||
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
|
||||
text = gimp_color_profile_get_label (profile);
|
||||
|
|
|
@ -718,17 +718,14 @@ gimp_color_scale_set_color_config (GimpColorScale *scale,
|
|||
g_signal_handlers_disconnect_by_func (priv->config,
|
||||
gimp_color_scale_notify_config,
|
||||
scale);
|
||||
g_object_unref (priv->config);
|
||||
|
||||
gimp_color_scale_destroy_transform (scale);
|
||||
}
|
||||
|
||||
priv->config = config;
|
||||
g_set_object (&priv->config, config);
|
||||
|
||||
if (priv->config)
|
||||
{
|
||||
g_object_ref (priv->config);
|
||||
|
||||
g_signal_connect (priv->config, "notify",
|
||||
G_CALLBACK (gimp_color_scale_notify_config),
|
||||
scale);
|
||||
|
|
|
@ -634,17 +634,14 @@ gimp_color_select_set_config (GimpColorSelector *selector,
|
|||
g_signal_handlers_disconnect_by_func (select->config,
|
||||
gimp_color_select_notify_config,
|
||||
select);
|
||||
g_object_unref (select->config);
|
||||
|
||||
gimp_color_select_destroy_transform (select);
|
||||
}
|
||||
|
||||
select->config = config;
|
||||
g_set_object (&select->config, config);
|
||||
|
||||
if (select->config)
|
||||
{
|
||||
g_object_ref (select->config);
|
||||
|
||||
g_signal_connect (select->config, "notify",
|
||||
G_CALLBACK (gimp_color_select_notify_config),
|
||||
select);
|
||||
|
|
|
@ -941,16 +941,7 @@ gimp_preview_set_default_cursor (GimpPreview *preview,
|
|||
|
||||
priv = GET_PRIVATE (preview);
|
||||
|
||||
if (cursor != priv->default_cursor)
|
||||
{
|
||||
if (priv->default_cursor)
|
||||
g_object_unref (priv->default_cursor);
|
||||
|
||||
if (cursor)
|
||||
g_object_ref (cursor);
|
||||
|
||||
priv->default_cursor = cursor;
|
||||
}
|
||||
g_set_object (&priv->default_cursor, cursor);
|
||||
}
|
||||
|
||||
GdkCursor *
|
||||
|
|
|
@ -1820,17 +1820,14 @@ gimp_preview_area_set_color_config (GimpPreviewArea *area,
|
|||
g_signal_handlers_disconnect_by_func (priv->config,
|
||||
gimp_preview_area_destroy_transform,
|
||||
area);
|
||||
g_object_unref (priv->config);
|
||||
|
||||
gimp_preview_area_destroy_transform (area);
|
||||
}
|
||||
|
||||
priv->config = config;
|
||||
g_set_object (&priv->config, config);
|
||||
|
||||
if (priv->config)
|
||||
{
|
||||
g_object_ref (priv->config);
|
||||
|
||||
g_signal_connect_swapped (priv->config, "notify",
|
||||
G_CALLBACK (gimp_preview_area_destroy_transform),
|
||||
area);
|
||||
|
|
|
@ -270,22 +270,16 @@ colorsel_cmyk_set_config (GimpColorSelector *selector,
|
|||
if (config != module->config)
|
||||
{
|
||||
if (module->config)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (module->config,
|
||||
colorsel_cmyk_config_changed,
|
||||
module);
|
||||
g_object_unref (module->config);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (module->config,
|
||||
colorsel_cmyk_config_changed,
|
||||
module);
|
||||
|
||||
module->config = config;
|
||||
g_set_object (&module->config, config);
|
||||
|
||||
if (module->config)
|
||||
{
|
||||
g_object_ref (module->config);
|
||||
g_signal_connect_swapped (module->config, "notify",
|
||||
G_CALLBACK (colorsel_cmyk_config_changed),
|
||||
module);
|
||||
}
|
||||
g_signal_connect_swapped (module->config, "notify",
|
||||
G_CALLBACK (colorsel_cmyk_config_changed),
|
||||
module);
|
||||
|
||||
colorsel_cmyk_config_changed (module);
|
||||
}
|
||||
|
|
|
@ -235,17 +235,14 @@ colorsel_water_set_config (GimpColorSelector *selector,
|
|||
g_signal_handlers_disconnect_by_func (water->config,
|
||||
colorsel_water_destroy_transform,
|
||||
water);
|
||||
g_object_unref (water->config);
|
||||
|
||||
colorsel_water_destroy_transform (water);
|
||||
}
|
||||
|
||||
water->config = config;
|
||||
g_set_object (&water->config, config);
|
||||
|
||||
if (water->config)
|
||||
{
|
||||
g_object_ref (water->config);
|
||||
|
||||
g_signal_connect_swapped (water->config, "notify",
|
||||
G_CALLBACK (colorsel_water_destroy_transform),
|
||||
water);
|
||||
|
|
|
@ -1463,17 +1463,14 @@ gimp_color_wheel_set_color_config (GimpColorWheel *wheel,
|
|||
g_signal_handlers_disconnect_by_func (priv->config,
|
||||
gimp_color_wheel_destroy_transform,
|
||||
wheel);
|
||||
g_object_unref (priv->config);
|
||||
|
||||
gimp_color_wheel_destroy_transform (wheel);
|
||||
}
|
||||
|
||||
priv->config = config;
|
||||
g_set_object (&priv->config, config);
|
||||
|
||||
if (priv->config)
|
||||
{
|
||||
g_object_ref (priv->config);
|
||||
|
||||
g_signal_connect_swapped (priv->config, "notify",
|
||||
G_CALLBACK (gimp_color_wheel_destroy_transform),
|
||||
wheel);
|
||||
|
|
Loading…
Reference in a new issue