summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-12-11 04:02:49 +0000
committerMatthias Clasen <mclasen@redhat.com>2022-12-11 04:02:49 +0000
commit973a8752abc16234301a4fde8f34045c97f99ed8 (patch)
tree3882a913ed0a2517f0365423c1905f02ddbb63ee
parentdb3b216ad174f611f60176ab3447148475844bd6 (diff)
parentb3b5a5064eb802b4f2c2a92943e521cbb54801e0 (diff)
downloadgtk+-973a8752abc16234301a4fde8f34045c97f99ed8.tar.gz
Merge branch 'ebassi/image-dispose' into 'main'
Do not change the notification queue inside finalization Closes #5420 See merge request GNOME/gtk!5321
-rw-r--r--gtk/gtkimage.c88
1 files changed, 52 insertions, 36 deletions
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index db99d57713..d8864fdc17 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -19,7 +19,7 @@
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
@@ -128,6 +128,8 @@ static void gtk_image_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
+static void gtk_image_clear_internal (GtkImage *self,
+ gboolean notify);
enum
{
@@ -295,7 +297,7 @@ gtk_image_finalize (GObject *object)
{
GtkImage *image = GTK_IMAGE (object);
- gtk_image_clear (image);
+ gtk_image_clear_internal (image, FALSE);
g_clear_object (&image->icon_helper);
@@ -348,7 +350,7 @@ gtk_image_set_property (GObject *object,
}
}
-static void
+static void
gtk_image_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -484,7 +486,7 @@ gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf)
gtk_image_set_from_pixbuf (image, pixbuf);
- return GTK_WIDGET (image);
+ return GTK_WIDGET (image);
}
/**
@@ -511,7 +513,7 @@ gtk_image_new_from_paintable (GdkPaintable *paintable)
gtk_image_set_from_paintable (image, paintable);
- return GTK_WIDGET (image);
+ return GTK_WIDGET (image);
}
/**
@@ -787,7 +789,7 @@ gtk_image_set_from_gicon (GtkImage *image,
}
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_GICON]);
-
+
g_object_thaw_notify (G_OBJECT (image));
}
@@ -849,7 +851,7 @@ gtk_image_set_from_paintable (GtkImage *image,
}
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_PAINTABLE]);
-
+
g_object_thaw_notify (G_OBJECT (image));
}
@@ -1061,7 +1063,7 @@ gtk_image_set_from_definition (GtkImage *image,
g_return_if_fail (GTK_IS_IMAGE (image));
g_object_freeze_notify (G_OBJECT (image));
-
+
gtk_image_clear (image);
if (def != NULL)
@@ -1080,59 +1082,73 @@ gtk_image_get_definition (GtkImage *image)
return gtk_icon_helper_get_definition (image->icon_helper);
}
-/**
- * gtk_image_clear:
- * @image: a `GtkImage`
- *
- * Resets the image to be empty.
- */
-void
-gtk_image_clear (GtkImage *image)
+static void
+gtk_image_clear_internal (GtkImage *self,
+ gboolean notify)
{
- GtkImageType storage_type;
+ GtkImageType storage_type = gtk_image_get_storage_type (self);
+ GObject *gobject = G_OBJECT (self);
- g_object_freeze_notify (G_OBJECT (image));
- storage_type = gtk_image_get_storage_type (image);
+ if (notify)
+ {
+ if (storage_type != GTK_IMAGE_EMPTY)
+ g_object_notify_by_pspec (gobject, image_props[PROP_STORAGE_TYPE]);
- if (storage_type != GTK_IMAGE_EMPTY)
- g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_STORAGE_TYPE]);
+ g_object_notify_by_pspec (gobject, image_props[PROP_ICON_SIZE]);
- g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_ICON_SIZE]);
-
- gtk_image_notify_for_storage_type (image, storage_type);
+ gtk_image_notify_for_storage_type (self, storage_type);
+ }
- if (image->filename)
+ if (self->filename)
{
- g_free (image->filename);
- image->filename = NULL;
- g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_FILE]);
+ g_free (self->filename);
+ self->filename = NULL;
+
+ if (notify)
+ g_object_notify_by_pspec (gobject, image_props[PROP_FILE]);
}
- if (image->resource_path)
+ if (self->resource_path)
{
- g_free (image->resource_path);
- image->resource_path = NULL;
- g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_RESOURCE]);
+ g_free (self->resource_path);
+ self->resource_path = NULL;
+
+ if (notify)
+ g_object_notify_by_pspec (gobject, image_props[PROP_RESOURCE]);
}
if (storage_type == GTK_IMAGE_PAINTABLE)
{
- GdkPaintable *paintable = _gtk_icon_helper_peek_paintable (image->icon_helper);
+ GdkPaintable *paintable = _gtk_icon_helper_peek_paintable (self->icon_helper);
const guint flags = gdk_paintable_get_flags (paintable);
if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
g_signal_handlers_disconnect_by_func (paintable,
gtk_image_paintable_invalidate_contents,
- image);
+ self);
if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
g_signal_handlers_disconnect_by_func (paintable,
gtk_image_paintable_invalidate_size,
- image);
+ self);
}
- _gtk_icon_helper_clear (image->icon_helper);
+ _gtk_icon_helper_clear (self->icon_helper);
+}
+
+/**
+ * gtk_image_clear:
+ * @image: a `GtkImage`
+ *
+ * Resets the image to be empty.
+ */
+void
+gtk_image_clear (GtkImage *image)
+{
+ g_return_if_fail (GTK_IS_IMAGE (image));
+ g_object_freeze_notify (G_OBJECT (image));
+ gtk_image_clear_internal (image, TRUE);
g_object_thaw_notify (G_OBJECT (image));
}