[gimp] app: make the active_image into a weak pointer.



commit 576e804ebf5a66d0e5efca098056ddb5bf638018
Author: Jehan <jehan girinstud io>
Date:   Mon Mar 18 11:20:04 2019 +0100

    app: make the active_image into a weak pointer.
    
    We should make sure the object exists before using it.

 app/widgets/gimpcolormapselection.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/app/widgets/gimpcolormapselection.c b/app/widgets/gimpcolormapselection.c
index f07bf53edb..9b49a17b89 100644
--- a/app/widgets/gimpcolormapselection.c
+++ b/app/widgets/gimpcolormapselection.c
@@ -678,9 +678,14 @@ gimp_colormap_selection_image_changed (GimpColormapSelection *selection,
 {
   if (selection->active_image)
     {
+      g_object_remove_weak_pointer (G_OBJECT (selection->active_image),
+                                    (gpointer) &selection->active_image);
       g_signal_handlers_disconnect_by_func (selection->active_image,
                                             G_CALLBACK (gtk_widget_queue_draw),
                                             selection);
+      g_signal_handlers_disconnect_by_func (selection->active_image,
+                                            G_CALLBACK (gimp_colormap_selection_set_palette),
+                                            selection);
       if (gimp_image_get_base_type (selection->active_image) == GIMP_INDEXED)
         {
           GimpPalette *palette;
@@ -713,6 +718,8 @@ gimp_colormap_selection_image_changed (GimpColormapSelection *selection,
   selection->active_image = image;
   if (image)
     {
+      g_object_add_weak_pointer (G_OBJECT (selection->active_image),
+                                 (gpointer) &selection->active_image);
       g_signal_connect_swapped (image, "colormap-changed",
                                 G_CALLBACK (gtk_widget_queue_draw),
                                 selection);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]