Commit 5561da87 authored by Ell's avatar Ell

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.
parent d56d663e
......@@ -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);
......
......@@ -41,6 +41,7 @@ struct _GimpHistogramEditor
GimpDrawable *drawable;
GimpHistogram *histogram;
GimpHistogram *bg_histogram;
GimpAsync *calculate_async;
guint idle_id;
gboolean recompute;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment