summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2023-10-13 17:49:28 +0200
committerChristian Soffke <christian.soffke@gmail.com>2023-10-18 18:23:57 +0200
commit759aaecdffc3302cf965ade7aef9c2742a9270f3 (patch)
tree0b93364f6f67936c07d5fb9a91f9bc36b6ba25e6
parent9cd4943950fe6ddace97ac09671b7883cdb44949 (diff)
downloadrockbox-759aaecdff.tar.gz
rockbox-759aaecdff.zip
Playlist Viewer: Eliminate 'dirty' flag
A playlist's explicit 'modified' flag is now used for keeping track of whether it's been modified in the Playlist Viewer, not just in case of the currently playing list, but for other playlists as well. When you start playback of a track from the Playlist Viewer, a playlist's 'modified' status is now carried over to the current playlist, so as to produce a warning when there is an attempt to replace the list at a later point. This also prevents (auto) bookmarking of the playlist if it had been modified in the Playlist Viewer prior to becoming the current playlist. (Bugfix) Change-Id: Ibc391fd69285f8a67d6ffb6d8c274df3d223974c
-rw-r--r--apps/playlist.c1
-rw-r--r--apps/playlist_viewer.c24
2 files changed, 12 insertions, 13 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 4440c77dbf..652f805aea 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -3780,6 +3780,7 @@ int playlist_set_current(struct playlist_info* playlist)
current_playlist.amount = playlist->amount;
current_playlist.last_insert_pos = playlist->last_insert_pos;
current_playlist.seed = playlist->seed;
+ current_playlist.flags = playlist->flags;
result = 0;
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index d12aa26de4..d780bfb7e9 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -121,8 +121,6 @@ static struct playlist_viewer viewer;
static struct playlist_info temp_playlist;
static bool temp_playlist_init = false;
-static bool dirty = false;
-
static void playlist_buffer_init(struct playlist_buffer *pb, char *names_buffer,
int names_buffer_size);
static void playlist_buffer_load_entries(struct playlist_buffer * pb, int index,
@@ -661,8 +659,14 @@ static enum pv_onplay_result onplay_menu(int index)
break;
case 6:
/* save playlist */
- if (!save_playlist_screen(viewer.playlist))
- dirty = false;
+ if (!save_playlist_screen(viewer.playlist) && viewer.playlist)
+ /*
+ * Set unmodified unless it's the current playlist, which may
+ * contain queued songs that aren't saved to the playlist file
+ * TODO: This can be removed once g5192 is merged,
+ * "playlist: Rewrite playlist_save(), optimization & fixes"
+ */
+ playlist_set_modified(viewer.playlist, false);
ret = PV_ONPLAY_UNCHANGED;
break;
case 7:
@@ -802,8 +806,7 @@ static bool update_viewer_with_changes(struct gui_synclist *playlist_lists, enum
if (res == PV_ONPLAY_CHANGED ||
res == PV_ONPLAY_ITEM_REMOVED)
{
- if (!viewer.playlist)
- playlist_set_modified(NULL, true);
+ playlist_set_modified(viewer.playlist, true);
if (res == PV_ONPLAY_ITEM_REMOVED)
gui_synclist_del_item(playlist_lists);
@@ -815,8 +818,6 @@ static bool update_viewer_with_changes(struct gui_synclist *playlist_lists, enum
if (viewer.selected_track >= viewer.num_tracks)
viewer.selected_track = viewer.num_tracks-1;
-
- dirty = true;
}
/* the show_icons option in the playlist viewer settings
@@ -956,13 +957,11 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
str(LANG_FAILED));
}
- if (!viewer.playlist)
- playlist_set_modified(NULL, true);
+ playlist_set_modified(viewer.playlist, true);
update_playlist(true);
viewer.moving_track = -1;
viewer.moving_playlist_index = -1;
- dirty = true;
}
else if (!viewer.playlist)
{
@@ -1128,11 +1127,10 @@ static void close_playlist_viewer(void)
if (viewer.initial_selection)
*(viewer.initial_selection) = viewer.selected_track;
- if(dirty && yesno_pop(ID2P(LANG_SAVE_CHANGES)))
+ if(playlist_modified(viewer.playlist) && yesno_pop(ID2P(LANG_SAVE_CHANGES)))
save_playlist_screen(viewer.playlist);
playlist_close(viewer.playlist);
}
- dirty = false;
}
static const char* playlist_search_callback_name(int selected_item, void * data,