[gtk] picture: Avoid some unnecessary signal connections
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] picture: Avoid some unnecessary signal connections
- Date: Mon, 31 Dec 2018 11:45:00 +0000 (UTC)
commit b4f2a3416ecfd4fbc86606b8c72a60097112b042
Author: Timm Bäder <mail baedert org>
Date: Fri Dec 21 09:26:38 2018 +0100
picture: Avoid some unnecessary signal connections
We don't need to ever invalidate the picture size if the paintable tells
us its size is static. Same for the contents.
gtk/gtkpicture.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkpicture.c b/gtk/gtkpicture.c
index ba81e517ab..1ae495c35d 100644
--- a/gtk/gtkpicture.c
+++ b/gtk/gtkpicture.c
@@ -798,26 +798,36 @@ gtk_picture_set_paintable (GtkPicture *self,
if (self->paintable)
{
- g_signal_handlers_disconnect_by_func (self->paintable,
- gtk_picture_paintable_invalidate_contents,
- self);
- g_signal_handlers_disconnect_by_func (self->paintable,
- gtk_picture_paintable_invalidate_size,
- self);
+ const guint flags = gdk_paintable_get_flags (self->paintable);
+
+ if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
+ g_signal_handlers_disconnect_by_func (self->paintable,
+ gtk_picture_paintable_invalidate_contents,
+ self);
+
+ if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
+ g_signal_handlers_disconnect_by_func (self->paintable,
+ gtk_picture_paintable_invalidate_size,
+ self);
}
self->paintable = paintable;
if (paintable)
{
- g_signal_connect (paintable,
- "invalidate-contents",
- G_CALLBACK (gtk_picture_paintable_invalidate_contents),
- self);
- g_signal_connect (paintable,
- "invalidate-size",
- G_CALLBACK (gtk_picture_paintable_invalidate_size),
- self);
+ const guint flags = gdk_paintable_get_flags (paintable);
+
+ if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
+ g_signal_connect (paintable,
+ "invalidate-contents",
+ G_CALLBACK (gtk_picture_paintable_invalidate_contents),
+ self);
+
+ if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
+ g_signal_connect (paintable,
+ "invalidate-size",
+ G_CALLBACK (gtk_picture_paintable_invalidate_size),
+ self);
}
gtk_widget_queue_resize (GTK_WIDGET (self));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]