[gimp] app: block edited signal in GimpDataFactory edited callback



commit 2213f29677e1a3e1ccee7ca18e8accc288c83d18
Author: Kristian Rietveld <kris loopnest org>
Date:   Fri Apr 15 23:25:08 2016 +0100

    app: block edited signal in GimpDataFactory edited callback
    
    This fixes a problem where in some cases the item next to the edited
    item was changed inadvertently. This was caused by the fact that
    the change of the label within the tree_name_edited callback triggered
    a re-ordering of the items, which triggered a stop editing signal, which
    finally caused a re-entrance in the tree_name_edited callback. By this
    time the item below "path_str" has changed, which caused the name of
    another object to be edited.

 app/widgets/gimpdatafactoryview.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpdatafactoryview.c b/app/widgets/gimpdatafactoryview.c
index e5d0b96..369ad03 100644
--- a/app/widgets/gimpdatafactoryview.c
+++ b/app/widgets/gimpdatafactoryview.c
@@ -592,6 +592,18 @@ gimp_data_factory_view_tree_name_edited (GtkCellRendererText *cell,
 
       name = g_strstrip (g_strdup (new_name));
 
+      /* We must block the edited callback at this point, because either
+       * the call to gimp_object_take_name() or gtk_tree_store_set() below
+       * will trigger a re-ordering and emission of the rows_reordered signal.
+       * This in turn will stop the editing operation and cause a call to this
+       * very callback function again. Because the order of the rows has
+       * changed by then, "path_str" will point at another item and cause the
+       * name of this item to be changed as well.
+       */
+      g_signal_handlers_block_by_func (cell,
+                                       gimp_data_factory_view_tree_name_edited,
+                                       view);
+
       if (gimp_data_is_writable (data) &&
           strlen (name)                &&
           g_strcmp0 (name, gimp_object_get_name (data)))
@@ -609,6 +621,10 @@ gimp_data_factory_view_tree_name_edited (GtkCellRendererText *cell,
           g_free (name);
         }
 
+      g_signal_handlers_unblock_by_func (cell,
+                                         gimp_data_factory_view_tree_name_edited,
+                                         view);
+
       g_object_unref (renderer);
     }
 


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