[gimp] app: avoiding infinite loops of signals calling each other.



commit bc83b283fd0bc93a2e0f7d75f37146956dbfe290
Author: Jehan <jehan girinstud io>
Date:   Wed Feb 2 18:12:14 2022 +0100

    app: avoiding infinite loops of signals calling each other.
    
    This is a better fix for the previously reverted commit, avoiding
    "floating-selection-changed" and "select-items" to recursively calling
    each other.
    
    The other fix on context update is similar and was also triggering
    crashes because of recursive signal calling after the previous revert.

 app/widgets/gimpcontainerview.c    | 8 ++++++++
 app/widgets/gimpdrawabletreeview.c | 7 +++++++
 2 files changed, 15 insertions(+)
---
diff --git a/app/widgets/gimpcontainerview.c b/app/widgets/gimpcontainerview.c
index 0147040d23..64365f3f64 100644
--- a/app/widgets/gimpcontainerview.c
+++ b/app/widgets/gimpcontainerview.c
@@ -1353,9 +1353,17 @@ gimp_container_view_context_changed (GimpContext       *context,
   if (viewable)
     viewables = g_list_prepend (viewables, viewable);
 
+  g_signal_handlers_block_by_func (context,
+                                   gimp_container_view_context_changed,
+                                   view);
+
   if (! gimp_container_view_select_items (view, viewables))
     g_warning ("%s: select_items() failed (should not happen)", G_STRFUNC);
 
+  g_signal_handlers_unblock_by_func (context,
+                                     gimp_container_view_context_changed,
+                                     view);
+
   g_list_free (viewables);
 }
 
diff --git a/app/widgets/gimpdrawabletreeview.c b/app/widgets/gimpdrawabletreeview.c
index 57687af879..f803fe0573 100644
--- a/app/widgets/gimpdrawabletreeview.c
+++ b/app/widgets/gimpdrawabletreeview.c
@@ -336,8 +336,15 @@ gimp_drawable_tree_view_floating_selection_changed (GimpImage            *image,
   item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (image);
 
   /*  update button states  */
+  g_signal_handlers_block_by_func (gimp_item_tree_view_get_image (view),
+                                   gimp_drawable_tree_view_floating_selection_changed,
+                                   view);
   gimp_container_view_select_item (GIMP_CONTAINER_VIEW (view),
                                    (GimpViewable *) item);
+  g_signal_handlers_unblock_by_func (gimp_item_tree_view_get_image (view),
+                                     gimp_drawable_tree_view_floating_selection_changed,
+                                     view);
+
 }
 
 static void


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