diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2023-10-13 17:49:28 +0200 |
---|---|---|
committer | Christian Soffke <christian.soffke@gmail.com> | 2023-10-18 18:23:57 +0200 |
commit | 759aaecdffc3302cf965ade7aef9c2742a9270f3 (patch) | |
tree | 0b93364f6f67936c07d5fb9a91f9bc36b6ba25e6 /apps/playlist_viewer.c | |
parent | 9cd4943950fe6ddace97ac09671b7883cdb44949 (diff) | |
download | rockbox-759aaecdffc3302cf965ade7aef9c2742a9270f3.tar.gz rockbox-759aaecdffc3302cf965ade7aef9c2742a9270f3.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
Diffstat (limited to 'apps/playlist_viewer.c')
-rw-r--r-- | apps/playlist_viewer.c | 24 |
1 files changed, 11 insertions, 13 deletions
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; | |||
121 | static struct playlist_info temp_playlist; | 121 | static struct playlist_info temp_playlist; |
122 | static bool temp_playlist_init = false; | 122 | static bool temp_playlist_init = false; |
123 | 123 | ||
124 | static bool dirty = false; | ||
125 | |||
126 | static void playlist_buffer_init(struct playlist_buffer *pb, char *names_buffer, | 124 | static void playlist_buffer_init(struct playlist_buffer *pb, char *names_buffer, |
127 | int names_buffer_size); | 125 | int names_buffer_size); |
128 | static void playlist_buffer_load_entries(struct playlist_buffer * pb, int index, | 126 | 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) | |||
661 | break; | 659 | break; |
662 | case 6: | 660 | case 6: |
663 | /* save playlist */ | 661 | /* save playlist */ |
664 | if (!save_playlist_screen(viewer.playlist)) | 662 | if (!save_playlist_screen(viewer.playlist) && viewer.playlist) |
665 | dirty = false; | 663 | /* |
664 | * Set unmodified unless it's the current playlist, which may | ||
665 | * contain queued songs that aren't saved to the playlist file | ||
666 | * TODO: This can be removed once g5192 is merged, | ||
667 | * "playlist: Rewrite playlist_save(), optimization & fixes" | ||
668 | */ | ||
669 | playlist_set_modified(viewer.playlist, false); | ||
666 | ret = PV_ONPLAY_UNCHANGED; | 670 | ret = PV_ONPLAY_UNCHANGED; |
667 | break; | 671 | break; |
668 | case 7: | 672 | case 7: |
@@ -802,8 +806,7 @@ static bool update_viewer_with_changes(struct gui_synclist *playlist_lists, enum | |||
802 | if (res == PV_ONPLAY_CHANGED || | 806 | if (res == PV_ONPLAY_CHANGED || |
803 | res == PV_ONPLAY_ITEM_REMOVED) | 807 | res == PV_ONPLAY_ITEM_REMOVED) |
804 | { | 808 | { |
805 | if (!viewer.playlist) | 809 | playlist_set_modified(viewer.playlist, true); |
806 | playlist_set_modified(NULL, true); | ||
807 | 810 | ||
808 | if (res == PV_ONPLAY_ITEM_REMOVED) | 811 | if (res == PV_ONPLAY_ITEM_REMOVED) |
809 | gui_synclist_del_item(playlist_lists); | 812 | gui_synclist_del_item(playlist_lists); |
@@ -815,8 +818,6 @@ static bool update_viewer_with_changes(struct gui_synclist *playlist_lists, enum | |||
815 | 818 | ||
816 | if (viewer.selected_track >= viewer.num_tracks) | 819 | if (viewer.selected_track >= viewer.num_tracks) |
817 | viewer.selected_track = viewer.num_tracks-1; | 820 | viewer.selected_track = viewer.num_tracks-1; |
818 | |||
819 | dirty = true; | ||
820 | } | 821 | } |
821 | 822 | ||
822 | /* the show_icons option in the playlist viewer settings | 823 | /* the show_icons option in the playlist viewer settings |
@@ -956,13 +957,11 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename, | |||
956 | str(LANG_FAILED)); | 957 | str(LANG_FAILED)); |
957 | } | 958 | } |
958 | 959 | ||
959 | if (!viewer.playlist) | 960 | playlist_set_modified(viewer.playlist, true); |
960 | playlist_set_modified(NULL, true); | ||
961 | 961 | ||
962 | update_playlist(true); | 962 | update_playlist(true); |
963 | viewer.moving_track = -1; | 963 | viewer.moving_track = -1; |
964 | viewer.moving_playlist_index = -1; | 964 | viewer.moving_playlist_index = -1; |
965 | dirty = true; | ||
966 | } | 965 | } |
967 | else if (!viewer.playlist) | 966 | else if (!viewer.playlist) |
968 | { | 967 | { |
@@ -1128,11 +1127,10 @@ static void close_playlist_viewer(void) | |||
1128 | if (viewer.initial_selection) | 1127 | if (viewer.initial_selection) |
1129 | *(viewer.initial_selection) = viewer.selected_track; | 1128 | *(viewer.initial_selection) = viewer.selected_track; |
1130 | 1129 | ||
1131 | if(dirty && yesno_pop(ID2P(LANG_SAVE_CHANGES))) | 1130 | if(playlist_modified(viewer.playlist) && yesno_pop(ID2P(LANG_SAVE_CHANGES))) |
1132 | save_playlist_screen(viewer.playlist); | 1131 | save_playlist_screen(viewer.playlist); |
1133 | playlist_close(viewer.playlist); | 1132 | playlist_close(viewer.playlist); |
1134 | } | 1133 | } |
1135 | dirty = false; | ||
1136 | } | 1134 | } |
1137 | 1135 | ||
1138 | static const char* playlist_search_callback_name(int selected_item, void * data, | 1136 | static const char* playlist_search_callback_name(int selected_item, void * data, |