xaizek / pms (License: GPLv3+) (since 2018-12-07)
Older version of Practical Music Search written in C++.
Commit d37f261eda420fcf5c1f92b5aec27ed51201d0ba

fixed: pms would crash on song deletion from a playlist, and the fix broke the library view ->pos.
Author: Kim Tore Jensen
Author date (UTC): 2010-05-14 10:26
Committer name: Kim Tore Jensen
Committer date (UTC): 2010-05-14 10:26
Parent(s): bacc92c52ae373c98017ceb74ae0ebf3143ec063
Signing key:
Tree: 7b4f3cd3c35373087cdf84c816520e6f6921e3c2
File Lines added Lines deleted
src/command.cpp 2 0
src/display.cpp 1 1
src/list.cpp 4 7
src/list.h 9 0
File src/command.cpp changed (mode: 100644) (index ca09c0f..7788580)
... ... Control::Control(Connection * n_conn)
158 158 _has_new_library = false; _has_new_library = false;
159 159 _playlist = new Songlist; _playlist = new Songlist;
160 160 _library = new Songlist; _library = new Songlist;
161 _playlist->role = LIST_ROLE_MAIN;
162 _library->role = LIST_ROLE_LIBRARY;
161 163 _active = NULL; _active = NULL;
162 164 command_mode = 0; command_mode = 0;
163 165 mutevolume = 0; mutevolume = 0;
File src/display.cpp changed (mode: 100644) (index 476e8f3..1064bf7)
... ... void pms_win_playlist::draw()
734 734 } }
735 735 else if (pms->cursong() && song->file == pms->cursong()->file) else if (pms->cursong() && song->file == pms->cursong()->file)
736 736 { {
737 if (song->pos == MPD_SONG_NO_NUM || pms->cursong()->pos == song->pos)
737 if (list->role != LIST_ROLE_MAIN || (list->role == LIST_ROLE_MAIN && pms->cursong()->pos == song->pos))
738 738 { {
739 739 hilight = pms->options->colors->current; hilight = pms->options->colors->current;
740 740 } }
File src/list.cpp changed (mode: 100644) (index 4c15ad7..8e48718)
... ... Songlist::Songlist()
53 53 filename = ""; filename = "";
54 54 selection.size = 0; selection.size = 0;
55 55 selection.length = 0; selection.length = 0;
56 role = LIST_ROLE_PLAYLIST;
56 57 ignorecase = pms->options->get_bool("ignorecase"); ignorecase = pms->options->get_bool("ignorecase");
57 58 } }
58 59
 
... ... Song * Songlist::nextsong(song_t * id)
93 94 } }
94 95
95 96 /* Find the current song in this list */ /* Find the current song in this list */
96 if (s->pos != MPD_SONG_NO_NUM)
97 if (s->pos != MPD_SONG_NO_NUM && role == LIST_ROLE_MAIN)
97 98 i = match(Pms::tostring(pms->cursong()->pos), 0, end(), MATCH_POS); i = match(Pms::tostring(pms->cursong()->pos), 0, end(), MATCH_POS);
98 99
99 100 if (i == MATCH_FAILED) if (i == MATCH_FAILED)
 
... ... song_t Songlist::add(Song * song)
494 495 songs.push_back(song); songs.push_back(song);
495 496 if (filter_match(song)) if (filter_match(song))
496 497 filtersongs.push_back(song); filtersongs.push_back(song);
498 song->pos = static_cast<song_t>(songs.size() - 1);
497 499 } }
498 500 else else
499 501 { {
 
... ... song_t Songlist::add(Song * song)
508 510 /* FIXME: filtersongs does not get updated because of ->pos mismatch, but do we need it anyway? */ /* FIXME: filtersongs does not get updated because of ->pos mismatch, but do we need it anyway? */
509 511 } }
510 512
511 if (song->pos == MPD_SONG_NO_NUM)
512 {
513 song->pos = static_cast<song_t>(songs.size() - 1);
514 }
515
516 513 if (song->time != MPD_SONG_NO_TIME) if (song->time != MPD_SONG_NO_TIME)
517 514 { {
518 515 length += song->time; length += song->time;
 
... ... bool Songlist::gotocurrent()
723 720
724 721 if (!pms->cursong()) return false; if (!pms->cursong()) return false;
725 722
726 if (pms->cursong()->pos != MPD_SONG_NO_NUM)
723 if (pms->cursong()->pos != MPD_SONG_NO_NUM && role == LIST_ROLE_MAIN)
727 724 i = match(Pms::tostring(pms->cursong()->pos), 0, end(), MATCH_POS | MATCH_EXACT); i = match(Pms::tostring(pms->cursong()->pos), 0, end(), MATCH_POS | MATCH_EXACT);
728 725 if (i == MATCH_FAILED) if (i == MATCH_FAILED)
729 726 i = match(pms->cursong()->file, 0, end(), MATCH_FILE | MATCH_EXACT); i = match(pms->cursong()->file, 0, end(), MATCH_FILE | MATCH_EXACT);
File src/list.h changed (mode: 100644) (index 6a31589..e4d5228)
... ... enum
70 70 MATCH_GTE = 1 << 25 MATCH_GTE = 1 << 25
71 71 }; };
72 72
73 typedef enum
74 {
75 LIST_ROLE_MAIN,
76 LIST_ROLE_LIBRARY,
77 LIST_ROLE_PLAYLIST
78 }
79 List_role;
80
73 81 struct Selection struct Selection
74 82 { {
75 83 song_t size; song_t size;
 
... ... public:
99 107
100 108 bool ignorecase; bool ignorecase;
101 109 bool wrap; bool wrap;
110 List_role role;
102 111 string filename; string filename;
103 112
104 113 Song * song(song_t); Song * song(song_t);
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/pms

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/pms

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master