[gimp] app: in GimpHistogramEditor, cancel ongoing async upon update
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: in GimpHistogramEditor, cancel ongoing async upon update
- Date: Fri, 4 Jan 2019 13:18:28 +0000 (UTC)
commit 5561da87e6f17336b91aa59c39ebae97d8967838
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.
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 6d72c3228e..3212d3f625 100644
--- a/app/widgets/gimphistogrameditor.c
+++ b/app/widgets/gimphistogrameditor.c
@@ -460,6 +460,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);
}
@@ -496,6 +498,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,
@@ -564,6 +568,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 1bd3a4b109..b1dbfb56dd 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]