[gimp] app: in GimpTransformGridTool, avoid unnecessarily flushing image when pushing undo



commit ee425f88d812ebd835d27319e320acff4f675a49
Author: Ell <ell_se yahoo com>
Date:   Mon Jan 6 11:57:17 2020 +0200

    app: in GimpTransformGridTool, avoid unnecessarily flushing image when pushing undo
    
    In gimp_transform_grid_tool_push_internal_undo(), only flush the
    image when undo/redo availability for the tool changes, instead of
    for every undo step.  This speeds things up when many undo steps
    are pushed in succession, which usually happens when using the tool
    GUI.

 app/tools/gimptransformgridtool.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/app/tools/gimptransformgridtool.c b/app/tools/gimptransformgridtool.c
index bc9ad171cf..68311259db 100644
--- a/app/tools/gimptransformgridtool.c
+++ b/app/tools/gimptransformgridtool.c
@@ -1613,6 +1613,10 @@ gimp_transform_grid_tool_push_internal_undo (GimpTransformGridTool *tg_tool)
   if (! trans_infos_equal (undo_info->trans_infos, tg_tool->trans_infos))
     {
       GimpTransformOptions *tr_options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tg_tool);
+      gboolean              flush = FALSE;
+
+      if (tg_tool->undo_list->next == NULL)
+        flush = TRUE;
 
       undo_info            = undo_info_new ();
       undo_info->direction = tr_options->direction;
@@ -1624,12 +1628,22 @@ gimp_transform_grid_tool_push_internal_undo (GimpTransformGridTool *tg_tool)
       /* If we undid anything and started interacting, we have to
        * discard the redo history
        */
-      g_list_free_full (tg_tool->redo_list, (GDestroyNotify) undo_info_free);
-      tg_tool->redo_list = NULL;
+      if (tg_tool->redo_list)
+        {
+          g_list_free_full (tg_tool->redo_list,
+                            (GDestroyNotify) undo_info_free);
+          tg_tool->redo_list = NULL;
+
+          flush = TRUE;
+        }
 
       gimp_transform_grid_tool_update_sensitivity (tg_tool);
 
       /*  update the undo actions / menu items  */
-      gimp_image_flush (gimp_display_get_image (GIMP_TOOL (tg_tool)->display));
+      if (flush)
+        {
+          gimp_image_flush (
+            gimp_display_get_image (GIMP_TOOL (tg_tool)->display));
+        }
     }
 }


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