[rhythmbox] podcast: handle return values from totem-pl-parser when cancelled
- From: Jonathan Matthew <jmatthew src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [rhythmbox] podcast: handle return values from totem-pl-parser when cancelled
 
- Date: Tue, 21 Jun 2022 12:00:53 +0000 (UTC)
 
commit 97df9fba504a4b1025c924d8a2b3f063dfbd5f5a
Author: Jonathan Matthew <jonathan d14n org>
Date:   Tue Jun 21 21:44:23 2022 +1000
    podcast: handle return values from totem-pl-parser when cancelled
    
    For some time, totem_pl_parser_parse_finish() has returned -1 when async
    parsing is cancelled, and now (as of GNOME/totem-pl-parser!49) it
    returns TOTEM_PL_PARSER_RESULT_CANCELLED.  Both of these possibilities
    need to be handled rather than causing an assertion failure, since we
    cancel all outstanding feed parsing when shutting down.  The code
    calling this expects a G_IO_ERROR_CANCELLED error to indicate the parser
    was cancelled, so ensure that's what we provide regardless of what the
    parser gave us.
    
    Fixes: #1988
 podcast/rb-podcast-parse.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/podcast/rb-podcast-parse.c b/podcast/rb-podcast-parse.c
index 42a8300fa..5819658a2 100644
--- a/podcast/rb-podcast-parse.c
+++ b/podcast/rb-podcast-parse.c
@@ -170,9 +170,21 @@ parse_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
        RBPodcastParseData *data = user_data;
        RBPodcastChannel *channel = data->channel;
        GError *error = NULL;
+       int result;
 
        channel->status = RB_PODCAST_PARSE_STATUS_ERROR;
-       switch (totem_pl_parser_parse_finish (TOTEM_PL_PARSER (source_object), res, &error)) {
+       result = totem_pl_parser_parse_finish (TOTEM_PL_PARSER (source_object), res, &error);
+
+       switch (result) {
+       case -1:                /* some versions of totem-pl-parser return this when cancelled */
+       case TOTEM_PL_PARSER_RESULT_CANCELLED:
+               rb_debug ("parsing of %s cancelled", channel->url);
+
+               /* ensure we have a G_IO_ERROR_CANCELLED error */
+               g_clear_error (&error);
+               g_set_error (&error, G_IO_ERROR, G_IO_ERROR_CANCELLED, " ");
+               break;
+
        case TOTEM_PL_PARSER_RESULT_ERROR:
        case TOTEM_PL_PARSER_RESULT_IGNORED:
        case TOTEM_PL_PARSER_RESULT_UNHANDLED:
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]