From fd9879e5ffba2c58b897155b39ff79584b3618e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 21 Dec 2018 09:26:38 +0100 Subject: [PATCH] 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));