Commit 171e4ed3 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

image preloader: call the callback even after cancelling

parent 414b6c25
......@@ -2310,11 +2310,13 @@ get_original_image_ready_cb (GObject *source_object,
cairo_surface_t *image = NULL;
GError *error = NULL;
gth_image_viewer_page_get_original_finish (self->viewer_page,
result,
&image,
&error);
gth_image_task_set_destination_surface (GTH_IMAGE_TASK (self), image);
if (gth_image_viewer_page_get_original_finish (self->viewer_page,
result,
&image,
&error))
{
gth_image_task_set_destination_surface (GTH_IMAGE_TASK (self), image);
}
gth_task_completed (GTH_TASK (self), error);
cairo_surface_destroy (image);
......
......@@ -223,6 +223,20 @@ load_request_unref (LoadRequest *request)
}
static void
load_request_completed_with_error (LoadRequest *request,
GQuark domain,
int code)
{
GError *error;
error = g_error_new_literal (domain, code, "");
g_simple_async_result_set_from_error (request->result, error);
g_error_free (error);
}
/* -- GthImagePreloader -- */
......@@ -417,14 +431,8 @@ _gth_image_preloader_request_completed (GthImagePreloader *self,
(GDestroyNotify) cache_data_unref);
g_simple_async_result_complete_in_idle (request->result);
}
else {
GError *error;
error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "");
g_simple_async_result_set_from_error (request->result, error);
g_error_free (error);
}
else
load_request_completed_with_error (request, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
}
/* queue the next file */
......@@ -752,10 +760,13 @@ _gth_image_preloader_cancel_current_request (GthImagePreloader *self)
if (self->priv->current_request == NULL)
return;
if (self->priv->load_next_id > 0) {
g_source_remove (self->priv->load_next_id);
self->priv->load_next_id = 0;
if ((self->priv->load_next_id > 0) || g_cancellable_is_cancelled (self->priv->current_request->cancellable)) {
if (self->priv->load_next_id > 0) {
g_source_remove (self->priv->load_next_id);
self->priv->load_next_id = 0;
}
load_request_completed_with_error (self->priv->current_request, G_IO_ERROR, G_IO_ERROR_CANCELLED);
_gth_image_preloader_request_finished (self, self->priv->current_request);
_gth_image_preloader_start_request (self, self->priv->last_request);
}
......
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