[gimp/gimp-2-10] app: work around GTK bug causing UI freeze during tree-view operations



commit f9a71fb6de5a2e65e0d88c6b7aaa39f589d6cdc4
Author: Ell <ell_se yahoo com>
Date:   Sat Jul 7 16:20:53 2018 -0400

    app: work around GTK bug causing UI freeze during tree-view operations
    
    In GimpContainerTreeView, work around a GTK bug which can cause the
    window containing the tree view to stop processing updates,
    resulting in an apprarent freeze, until update-processing is
    explicitly requested.  This can be triggered by adding layers to a
    layer group until the layers-dialog tree view is almost full, but
    still doesn't have a scrollbar, and then duplicating the group.
    
    This doesn't seem to affect GTK3, so not applying to master.

 app/widgets/gimpcontainertreeview.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c
index 8acd5a15ae..c055b1e2c4 100644
--- a/app/widgets/gimpcontainertreeview.c
+++ b/app/widgets/gimpcontainertreeview.c
@@ -107,6 +107,8 @@ static void          gimp_container_tree_view_name_started      (GtkCellRenderer
 static void          gimp_container_tree_view_name_canceled     (GtkCellRendererText         *cell,
                                                                  GimpContainerTreeView       *tree_view);
 
+static void          gimp_container_tree_view_cursor_changed    (GtkTreeView                 *view,
+                                                                 GimpContainerTreeView       *tree_view);
 static void          gimp_container_tree_view_selection_changed (GtkTreeSelection            *sel,
                                                                  GimpContainerTreeView       *tree_view);
 static gboolean      gimp_container_tree_view_button_press      (GtkWidget                   *widget,
@@ -138,6 +140,8 @@ static void          gimp_container_tree_view_expand_rows         (GtkTreeModel
 
 static void          gimp_container_tree_view_monitor_changed     (GimpContainerTreeView    *view);
 
+static void          gimp_container_tree_view_process_updates     (GimpContainerTreeView    *tree_view);
+
 
 G_DEFINE_TYPE_WITH_CODE (GimpContainerTreeView, gimp_container_tree_view,
                          GIMP_TYPE_CONTAINER_BOX,
@@ -265,6 +269,10 @@ gimp_container_tree_view_constructed (GObject *object)
 
   gimp_container_view_set_dnd_widget (view, GTK_WIDGET (tree_view->view));
 
+  g_signal_connect (tree_view->view, "cursor-changed",
+                    G_CALLBACK (gimp_container_tree_view_cursor_changed),
+                    tree_view);
+
   tree_view->main_column = gtk_tree_view_column_new ();
   gtk_tree_view_insert_column (tree_view->view, tree_view->main_column, 0);
 
@@ -1092,6 +1100,13 @@ gimp_container_tree_view_name_canceled (GtkCellRendererText   *cell,
     }
 }
 
+static void
+gimp_container_tree_view_cursor_changed (GtkTreeView           *view,
+                                         GimpContainerTreeView *tree_view)
+{
+  gimp_container_tree_view_process_updates (tree_view);
+}
+
 static void
 gimp_container_tree_view_selection_changed (GtkTreeSelection      *selection,
                                             GimpContainerTreeView *tree_view)
@@ -1102,6 +1117,8 @@ gimp_container_tree_view_selection_changed (GtkTreeSelection      *selection,
   gimp_container_tree_view_get_selected (view, &items);
   gimp_container_view_multi_selected (view, items);
   g_list_free (items);
+
+  gimp_container_tree_view_process_updates (tree_view);
 }
 
 static GtkCellRenderer *
@@ -1662,3 +1679,16 @@ gimp_container_tree_view_monitor_changed (GimpContainerTreeView *view)
                           gimp_container_tree_view_monitor_changed_foreach,
                           NULL);
 }
+
+static void
+gimp_container_tree_view_process_updates (GimpContainerTreeView *tree_view)
+{
+  GdkWindow *window = gtk_tree_view_get_bin_window (tree_view->view);
+
+  /* this is a hack, necessary to work around a gtk bug which can cause the
+   * window containing the tree view to stop processing updates until
+   * explicitly requested.
+   */
+  if (window)
+    gdk_window_process_updates (window, TRUE);
+}


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