[rhythmbox] podcast: throw away parsed data if the dialog has been reset



commit 5e8d1c1f96c7977db07d37b8f30cd5f55e2c403e
Author: Jonathan Matthew <jonathan d14n org>
Date:   Mon Jul 21 23:55:21 2014 +1000

    podcast: throw away parsed data if the dialog has been reset

 podcast/rb-podcast-add-dialog.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/podcast/rb-podcast-add-dialog.c b/podcast/rb-podcast-add-dialog.c
index 9315a99..93e481c 100644
--- a/podcast/rb-podcast-add-dialog.c
+++ b/podcast/rb-podcast-add-dialog.c
@@ -92,6 +92,7 @@ struct RBPodcastAddDialogPrivate
 
        int running_searches;
        gboolean search_successful;
+       int reset_count;
 };
 
 /* various prefixes that identify things we treat as feed URLs rather than search terms */
@@ -264,11 +265,22 @@ typedef struct {
        gboolean existing;
        gboolean single;
        GError *error;
+       int reset_count;
 } ParseThreadData;
 
 static gboolean
 parse_finished (ParseThreadData *data)
 {
+       if (data->reset_count != data->dialog->priv->reset_count) {
+               rb_debug ("dialog reset while parsing");
+               rb_podcast_parse_channel_free (data->channel);
+               g_object_unref (data->dialog);
+               g_clear_error (&data->error);
+               g_free (data->url);
+               g_free (data);
+               return FALSE;
+       }
+
        if (data->error != NULL) {
                gtk_label_set_label (GTK_LABEL (data->dialog->priv->info_bar_message),
                                     _("Unable to load the feed. Check your network connection."));
@@ -369,6 +381,7 @@ parse_in_thread (RBPodcastAddDialog *dialog, const char *text, gboolean existing
        data->channel = g_new0 (RBPodcastChannel, 1);
        data->existing = existing;
        data->single = single;
+       data->reset_count = dialog->priv->reset_count;
 
        g_thread_new ("podcast parser", (GThreadFunc) parse_thread, data);
 }
@@ -914,6 +927,7 @@ rb_podcast_add_dialog_class_init (RBPodcastAddDialogClass *klass)
 void
 rb_podcast_add_dialog_reset (RBPodcastAddDialog *dialog, const char *text, gboolean load)
 {
+       dialog->priv->reset_count++;
        remove_all_feeds (dialog);
        rhythmdb_entry_delete_by_type (dialog->priv->db, RHYTHMDB_ENTRY_TYPE_PODCAST_SEARCH);
        rhythmdb_commit (dialog->priv->db);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]