app: cancel async histogram calculation in gimp_histogram_clear_values()

Cancel any on-going asynchronous histogram calculation, started
through gimp_histogram_calculate_async(), upon calling
gimp_histogram_clear_values().
This commit is contained in:
Ell 2018-05-12 08:56:16 -04:00
parent 729240db34
commit d5b0b08431
1 changed files with 6 additions and 16 deletions

View File

@ -69,7 +69,6 @@ typedef struct
/* local function prototypes */
static void gimp_histogram_dispose (GObject *object);
static void gimp_histogram_finalize (GObject *object);
static void gimp_histogram_set_property (GObject *object,
guint property_id,
@ -108,7 +107,6 @@ gimp_histogram_class_init (GimpHistogramClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
object_class->dispose = gimp_histogram_dispose;
object_class->finalize = gimp_histogram_finalize;
object_class->set_property = gimp_histogram_set_property;
object_class->get_property = gimp_histogram_get_property;
@ -144,20 +142,6 @@ gimp_histogram_init (GimpHistogram *histogram)
histogram->priv->n_bins = 256;
}
static void
gimp_histogram_dispose (GObject *object)
{
GimpHistogram *histogram = GIMP_HISTOGRAM (object);
if (histogram->priv->calculate_async)
{
gimp_async_cancel (histogram->priv->calculate_async);
gimp_async_wait (histogram->priv->calculate_async);
}
G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
gimp_histogram_finalize (GObject *object)
{
@ -369,6 +353,12 @@ gimp_histogram_clear_values (GimpHistogram *histogram)
{
g_return_if_fail (GIMP_IS_HISTOGRAM (histogram));
if (histogram->priv->calculate_async)
{
gimp_async_cancel (histogram->priv->calculate_async);
gimp_async_wait (histogram->priv->calculate_async);
}
if (histogram->priv->values)
{
g_free (histogram->priv->values);