diff options
author | Gaël Bonithon <gael@xfce.org> | 2021-12-17 12:44:31 +0100 |
---|---|---|
committer | Gaël Bonithon <gael@xfce.org> | 2021-12-17 15:43:07 +0100 |
commit | 7bd0f5f61eec1769b24f67ad9509b856f4a967ad (patch) | |
tree | 3b0d7876769e9ae7694e215eb7dd768b5ae771f0 /plugins | |
parent | 71cbd765ecd904c260dcfdcd468bdd263c438c08 (diff) | |
download | tumbler-7bd0f5f61eec1769b24f67ad9509b856f4a967ad.tar.gz |
gst-thumbnailer: Fix error handling
Ensures that Tumbler emits the "error" signal if the pixbuf generation
didn't succeed and wasn't cancelled before the plugin handles the
request.
Similar to previous commit, related to #10.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gst-thumbnailer/gst-thumbnailer.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/plugins/gst-thumbnailer/gst-thumbnailer.c b/plugins/gst-thumbnailer/gst-thumbnailer.c index d080403..3ca6d6a 100644 --- a/plugins/gst-thumbnailer/gst-thumbnailer.c +++ b/plugins/gst-thumbnailer/gst-thumbnailer.c @@ -29,6 +29,7 @@ #include <math.h> #include <glib.h> +#include <glib/gi18n.h> #include <glib-object.h> #include <gdk-pixbuf/gdk-pixbuf.h> #include <tumbler/tumbler.h> @@ -565,16 +566,24 @@ gst_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, gint width, height; TumblerThumbnailFlavor *flavor; GdkPixbuf *scaled; + const gchar *uri; /* check for early cancellation */ if (g_cancellable_is_cancelled (cancellable)) return; /* Check if is a sparse video file */ + uri = tumbler_file_info_get_uri (info); if (tumbler_util_guess_is_sparse (info)) { - g_debug ("Video file '%s' is probably sparse, skipping\n", - tumbler_file_info_get_uri (info)); + g_debug ("Video file '%s' is probably sparse, skipping\n", uri); + + /* there was an error, emit error signal */ + g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, + TUMBLER_ERROR_MESSAGE_CREATION_FAILED); + g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_error_free (error); + return; } @@ -633,17 +642,25 @@ gst_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer, if (error != NULL) { - g_signal_emit_by_name (thumbnailer, "error", - tumbler_file_info_get_uri (info), - error->code, error->message); + g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); g_error_free (error); } else { - g_signal_emit_by_name (thumbnailer, "ready", - tumbler_file_info_get_uri (info)); + g_signal_emit_by_name (thumbnailer, "ready", uri); } } + else + { + /* there was an error, emit error signal */ + if (! g_cancellable_set_error_if_cancelled (cancellable, &error)) + g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_NO_CONTENT, + TUMBLER_ERROR_MESSAGE_CREATION_FAILED); + + g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message); + g_error_free (error); + } + g_object_unref (thumbnail); } |