[totem] main: Fix possible assertions when skipping over files



commit 5afb8011c469cf6f8ad94afa029701a92247e4be
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Mar 6 16:50:58 2013 +0100

    main: Fix possible assertions when skipping over files
    
    (totem:24342): Gtk-CRITICAL **: gtk_list_store_get_path: assertion `iter->stamp == priv->stamp' failed
    
    When the repeat mode was on, and reaching the end of the playlist,
    it was possible to cause a warning as we tried to read past the
    last iter in the list store.
    
    We change the semantics of totem_playlist_has_{next,previous}_mrl
    to not special case when "repeat" is on.

 src/totem-object.c   |    6 ++++--
 src/totem-playlist.c |   32 ++++++++++++--------------------
 2 files changed, 16 insertions(+), 22 deletions(-)
---
diff --git a/src/totem-object.c b/src/totem-object.c
index a9f4be5..907137b 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -3799,12 +3799,14 @@ update_buttons (TotemObject *totem)
 
        /* Previous */
        has_item = bacon_video_widget_has_previous_track (totem->bvw) ||
-               totem_playlist_has_previous_mrl (totem->playlist);
+               totem_playlist_has_previous_mrl (totem->playlist) ||
+               totem_playlist_get_repeat (totem->playlist);
        totem_action_set_sensitivity ("previous-chapter", has_item);
 
        /* Next */
        has_item = bacon_video_widget_has_next_track (totem->bvw) ||
-               totem_playlist_has_next_mrl (totem->playlist);
+               totem_playlist_has_next_mrl (totem->playlist) ||
+               totem_playlist_get_repeat (totem->playlist);
        totem_action_set_sensitivity ("next-chapter", has_item);
 }
 
diff --git a/src/totem-playlist.c b/src/totem-playlist.c
index 2cc8de2..b202234 100644
--- a/src/totem-playlist.c
+++ b/src/totem-playlist.c
@@ -2577,14 +2577,10 @@ totem_playlist_has_previous_mrl (TotemPlaylist *playlist)
        if (update_current_from_playlist (playlist) == FALSE)
                return FALSE;
 
-       if (playlist->priv->repeat != FALSE)
-               return TRUE;
-
-       if (playlist->priv->shuffle == FALSE)
-       {
+       if (playlist->priv->shuffle == FALSE) {
                gtk_tree_model_get_iter (playlist->priv->model,
-                               &iter,
-                               playlist->priv->current);
+                                        &iter,
+                                        playlist->priv->current);
 
                return gtk_tree_model_iter_previous (playlist->priv->model, &iter);
        } else {
@@ -2605,14 +2601,10 @@ totem_playlist_has_next_mrl (TotemPlaylist *playlist)
        if (update_current_from_playlist (playlist) == FALSE)
                return FALSE;
 
-       if (playlist->priv->repeat != FALSE)
-               return TRUE;
-
-       if (playlist->priv->shuffle == FALSE)
-       {
+       if (playlist->priv->shuffle == FALSE) {
                gtk_tree_model_get_iter (playlist->priv->model,
-                               &iter,
-                               playlist->priv->current);
+                                        &iter,
+                                        playlist->priv->current);
 
                return gtk_tree_model_iter_next (playlist->priv->model, &iter);
        } else {
@@ -2718,13 +2710,11 @@ totem_playlist_set_previous (TotemPlaylist *playlist)
 
        totem_playlist_unset_playing (playlist);
 
-       if (playlist->priv->shuffle == FALSE)
-       {
+       if (playlist->priv->shuffle == FALSE) {
                char *path;
 
                path = gtk_tree_path_to_string (playlist->priv->current);
-               if (strcmp (path, "0") == 0)
-               {
+               if (g_str_equal (path, "0")) {
                        totem_playlist_set_at_end (playlist);
                        g_free (path);
                        return;
@@ -2735,7 +2725,8 @@ totem_playlist_set_previous (TotemPlaylist *playlist)
                                &iter,
                                playlist->priv->current);
 
-               gtk_tree_model_iter_previous (playlist->priv->model, &iter);
+               if (!gtk_tree_model_iter_previous (playlist->priv->model, &iter))
+                       g_assert_not_reached ();
                gtk_tree_path_free (playlist->priv->current);
                playlist->priv->current = gtk_tree_model_get_path
                        (playlist->priv->model, &iter);
@@ -2774,7 +2765,8 @@ totem_playlist_set_next (TotemPlaylist *playlist)
                                         &iter,
                                         playlist->priv->current);
 
-               gtk_tree_model_iter_next (playlist->priv->model, &iter);
+               if (!gtk_tree_model_iter_next (playlist->priv->model, &iter))
+                       g_assert_not_reached ();
                gtk_tree_path_free (playlist->priv->current);
                playlist->priv->current = gtk_tree_model_get_path (playlist->priv->model, &iter);
        } else {


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