[gimp/metadata-browser] Bug 675994 - Opening image with a saved selection breaks histogram updating
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] Bug 675994 - Opening image with a saved selection breaks histogram updating
- Date: Thu, 13 Sep 2012 00:15:06 +0000 (UTC)
commit 3fb8c9d457fb1a39b574ec8d2425ee43cab99d89
Author: Michael Natterer <mitch gimp org>
Date: Mon May 14 01:44:41 2012 +0200
Bug 675994 - Opening image with a saved selection breaks histogram updating
In fact, it broke much more than that because the way XCF loading
replaced the image's mask prevented the image's "mask-changed" signal
from ever being emitted. Add private API gimp_image_take_mask() which
properly sets the mask and use it for image construction and the XCF
selection loading hack.
app/core/gimpimage-private.h | 3 +++
app/core/gimpimage.c | 35 ++++++++++++++++++++++++++---------
app/widgets/gimphistogrameditor.c | 3 +++
app/xcf/xcf-load.c | 9 +++------
4 files changed, 35 insertions(+), 15 deletions(-)
---
diff --git a/app/core/gimpimage-private.h b/app/core/gimpimage-private.h
index dd3e611..9daf1c8 100644
--- a/app/core/gimpimage-private.h
+++ b/app/core/gimpimage-private.h
@@ -112,5 +112,8 @@ struct _GimpImagePrivate
GIMP_TYPE_IMAGE, \
GimpImagePrivate)
+void gimp_image_take_mask (GimpImage *image,
+ GimpChannel *mask);
+
#endif /* __GIMP_IMAGE_PRIVATE_H__ */
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 719da3e..f31a88f 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -760,6 +760,7 @@ gimp_image_constructed (GObject *object)
{
GimpImage *image = GIMP_IMAGE (object);
GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
+ GimpChannel *selection;
GimpCoreConfig *config;
GimpTemplate *template;
@@ -785,15 +786,10 @@ gimp_image_constructed (GObject *object)
if (private->base_type == GIMP_INDEXED)
gimp_image_colormap_init (image);
- /* create the selection mask */
- private->selection_mask = gimp_selection_new (image,
- gimp_image_get_width (image),
- gimp_image_get_height (image));
- g_object_ref_sink (private->selection_mask);
-
- g_signal_connect (private->selection_mask, "update",
- G_CALLBACK (gimp_image_mask_update),
- image);
+ selection = gimp_selection_new (image,
+ gimp_image_get_width (image),
+ gimp_image_get_height (image));
+ gimp_image_take_mask (image, selection);
g_signal_connect_object (config, "notify::transparency-type",
G_CALLBACK (gimp_item_stack_invalidate_previews),
@@ -2095,6 +2091,27 @@ gimp_image_mask_changed (GimpImage *image)
g_signal_emit (image, gimp_image_signals[MASK_CHANGED], 0);
}
+void
+gimp_image_take_mask (GimpImage *image,
+ GimpChannel *mask)
+{
+ GimpImagePrivate *private;
+
+ g_return_if_fail (GIMP_IS_IMAGE (image));
+ g_return_if_fail (GIMP_IS_SELECTION (mask));
+
+ private = GIMP_IMAGE_GET_PRIVATE (image);
+
+ if (private->selection_mask)
+ g_object_unref (private->selection_mask);
+
+ private->selection_mask = g_object_ref_sink (mask);
+
+ g_signal_connect (private->selection_mask, "update",
+ G_CALLBACK (gimp_image_mask_update),
+ image);
+}
+
/* image components */
diff --git a/app/widgets/gimphistogrameditor.c b/app/widgets/gimphistogrameditor.c
index 1657d22..9a45333 100644
--- a/app/widgets/gimphistogrameditor.c
+++ b/app/widgets/gimphistogrameditor.c
@@ -250,6 +250,9 @@ gimp_histogram_editor_set_image (GimpImageEditor *image_editor,
}
g_signal_handlers_disconnect_by_func (image_editor->image,
+ gimp_histogram_editor_update,
+ editor);
+ g_signal_handlers_disconnect_by_func (image_editor->image,
gimp_histogram_editor_layer_changed,
editor);
g_signal_handlers_disconnect_by_func (image_editor->image,
diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c
index 0165863..8b38ed3 100644
--- a/app/xcf/xcf-load.c
+++ b/app/xcf/xcf-load.c
@@ -939,16 +939,13 @@ xcf_load_channel_props (XcfInfo *info,
case PROP_SELECTION:
{
- GimpImagePrivate *private = GIMP_IMAGE_GET_PRIVATE (image);
- GimpChannel *mask;
-
- g_object_unref (gimp_image_get_mask (image));
+ GimpChannel *mask;
- mask = private->selection_mask =
+ mask =
gimp_selection_new (image,
gimp_item_get_width (GIMP_ITEM (*channel)),
gimp_item_get_height (GIMP_ITEM (*channel)));
- g_object_ref_sink (mask);
+ gimp_image_take_mask (image, mask);
g_object_unref (GIMP_DRAWABLE (mask)->private->buffer);
GIMP_DRAWABLE (mask)->private->buffer =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]