[gimp/gimp-2-10] app: in GimpHistogramEditor, cancel ongoing async upon update



commit 5f00ee2a7d1107fdd75ab2eb7a7d30ec7c913db9
Author: Ell <ell_se yahoo com>
Date:   Fri Jan 4 08:10:55 2019 -0500

    app: in GimpHistogramEditor, cancel ongoing async upon update
    
    In gimp_histogram_editor_update(), cancel any ongoing histogram-
    calculation async before restarting the idle source.  The async
    will have been canceled anyway when recalculating the histogram
    once the idle source is run, but we can cancel it as soon as we
    know the histogram is outdated.
    
    (cherry picked from commit 5561da87e6f17336b91aa59c39ebae97d8967838)

 app/widgets/gimphistogrameditor.c | 7 +++++++
 app/widgets/gimphistogrameditor.h | 1 +
 2 files changed, 8 insertions(+)
---
diff --git a/app/widgets/gimphistogrameditor.c b/app/widgets/gimphistogrameditor.c
index 213799d188..2e485c8404 100644
--- a/app/widgets/gimphistogrameditor.c
+++ b/app/widgets/gimphistogrameditor.c
@@ -461,6 +461,8 @@ static void
 gimp_histogram_editor_calculate_async_callback (GimpAsync           *async,
                                                 GimpHistogramEditor *editor)
 {
+  editor->calculate_async = NULL;
+
   if (gimp_async_is_finished (async))
     gimp_histogram_editor_info_update (editor);
 }
@@ -497,6 +499,8 @@ gimp_histogram_editor_validate (GimpHistogramEditor *editor)
                                                            editor->histogram,
                                                            TRUE);
 
+          editor->calculate_async = async;
+
           gimp_async_add_callback (
             async,
             (GimpAsyncCallback) gimp_histogram_editor_calculate_async_callback,
@@ -565,6 +569,9 @@ gimp_histogram_editor_buffer_update (GimpHistogramEditor *editor,
 static void
 gimp_histogram_editor_update (GimpHistogramEditor *editor)
 {
+  if (editor->calculate_async)
+    gimp_async_cancel_and_wait (editor->calculate_async);
+
   if (editor->idle_id)
     g_source_remove (editor->idle_id);
 
diff --git a/app/widgets/gimphistogrameditor.h b/app/widgets/gimphistogrameditor.h
index 51f8f12a46..a3e663e2fa 100644
--- a/app/widgets/gimphistogrameditor.h
+++ b/app/widgets/gimphistogrameditor.h
@@ -41,6 +41,7 @@ struct _GimpHistogramEditor
   GimpDrawable         *drawable;
   GimpHistogram        *histogram;
   GimpHistogram        *bg_histogram;
+  GimpAsync            *calculate_async;
 
   guint                 idle_id;
   gboolean              recompute;


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