Commit dd0575ed authored by Michael Natterer's avatar Michael Natterer 😴

Move refing/unrefing the image to gimp_display_set_image()

and don't do it in gimp_display_connect()/disconnect() because
set_image() is the natural place to do it.
parent 067cfe9f
......@@ -30,36 +30,30 @@
/* local function prototypes */
static void gimp_display_update_handler (GimpProjection *projection,
gboolean now,
gint x,
gint y,
gint w,
gint h,
GimpDisplay *display);
static void gimp_display_flush_handler (GimpImage *image,
gboolean invalidate_preview,
GimpDisplay *display);
static void gimp_display_update_handler (GimpProjection *projection,
gboolean now,
gint x,
gint y,
gint w,
gint h,
GimpDisplay *display);
static void gimp_display_flush_handler (GimpImage *image,
gboolean invalidate_preview,
GimpDisplay *display);
/* public functions */
void
gimp_display_connect (GimpDisplay *display,
GimpImage *image)
gimp_display_connect (GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_DISPLAY (display));
g_return_if_fail (GIMP_IS_IMAGE (image));
g_return_if_fail (display->image == NULL);
GimpImage *image;
#if 0
g_print ("%s: image->ref_count before refing: %d\n",
G_STRFUNC, G_OBJECT (display->image)->ref_count);
#endif
g_return_if_fail (GIMP_IS_DISPLAY (display));
display->image = g_object_ref (image);
image = gimp_display_get_image (display);
image->disp_count++;
g_return_if_fail (GIMP_IS_IMAGE (image));
g_signal_connect (gimp_image_get_projection (image), "update",
G_CALLBACK (gimp_display_update_handler),
......@@ -76,9 +70,10 @@ gimp_display_disconnect (GimpDisplay *display)
GimpImage *image;
g_return_if_fail (GIMP_IS_DISPLAY (display));
g_return_if_fail (GIMP_IS_IMAGE (display->image));
image = display->image;
image = gimp_display_get_image (display);
g_return_if_fail (GIMP_IS_IMAGE (image));
g_signal_handlers_disconnect_by_func (image,
gimp_display_flush_handler,
......@@ -87,21 +82,6 @@ gimp_display_disconnect (GimpDisplay *display)
g_signal_handlers_disconnect_by_func (gimp_image_get_projection (image),
gimp_display_update_handler,
display);
image->disp_count--;
#if 0
g_print ("%s: image->ref_count before unrefing: %d\n",
G_STRFUNC, G_OBJECT (display->image)->ref_count);
#endif
/* set display->image to NULL before unrefing because there may be code
* that listens for image removals and then iterates the display list
* to find a valid display.
*/
display->image = NULL;
g_object_unref (image);
}
......
......@@ -19,8 +19,7 @@
#define __GIMP_DISPLAY_HANDLERS_H__
void gimp_display_connect (GimpDisplay *display,
GimpImage *image);
void gimp_display_connect (GimpDisplay *display);
void gimp_display_disconnect (GimpDisplay *display);
......
......@@ -627,16 +627,38 @@ gimp_display_set_image (GimpDisplay *display,
gimp_display_shell_disconnect (shell);
old_image = g_object_ref (display->image);
gimp_display_disconnect (display);
display->image->disp_count--;
/* set display->image before unrefing because there may be code
* that listens for image removals and then iterates the
* display list to find a valid display.
*/
old_image = display->image;
#if 0
g_print ("%s: image->ref_count before unrefing: %d\n",
G_STRFUNC, G_OBJECT (old_image)->ref_count);
#endif
}
display->image = image;
if (image)
{
#if 0
g_print ("%s: image->ref_count before refing: %d\n",
G_STRFUNC, G_OBJECT (image)->ref_count);
#endif
g_object_ref (image);
private->instance = image->instance_count++;
gimp_display_connect (display, image);
image->disp_count++;
gimp_display_connect (display);
if (shell)
gimp_display_shell_connect (shell);
......
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