libsaria: Tracks remove themselves from the list
This is mostly for when a library path is removed from the list. Tracks all remove themselves when destroyed, and then the library can be refreshed.
This commit is contained in:
parent
26979eb6a9
commit
2a9900c1e5
|
@ -39,6 +39,7 @@ namespace libsaria
|
|||
void for_each_path(void (*)(struct PathInfo &));
|
||||
|
||||
void list_track(libsaria::Track *);
|
||||
void unlist_track(libsaria::Track *);
|
||||
unsigned int size();
|
||||
void filter(string &text);
|
||||
bool is_visible(sid_t &);
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace libsaria
|
|||
|
||||
string *artist_lc;
|
||||
string *album_lc;
|
||||
bool needs_cleanup;
|
||||
void make_lenstr();
|
||||
void do_bookkeeping();
|
||||
|
||||
|
|
|
@ -24,6 +24,11 @@ namespace libsaria
|
|||
track_list.push_back(track);
|
||||
}
|
||||
|
||||
void library::unlist_track(libsaria::Track *track)
|
||||
{
|
||||
track_list.remove(track);
|
||||
}
|
||||
|
||||
void library::sort_list()
|
||||
{
|
||||
track_list.sort(compare_tracks);
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace libsaria
|
|||
|
||||
Track::Track()
|
||||
{
|
||||
needs_cleanup = false;
|
||||
}
|
||||
|
||||
Track::Track(string file, sid_t sid)
|
||||
|
@ -69,6 +70,8 @@ namespace libsaria
|
|||
|
||||
Track::~Track()
|
||||
{
|
||||
if (needs_cleanup)
|
||||
libsaria::library::unlist_track(this);
|
||||
}
|
||||
|
||||
void Track::do_bookkeeping()
|
||||
|
@ -77,6 +80,7 @@ namespace libsaria
|
|||
album_lc = lowercase(album);
|
||||
libsaria::index::add_track(this);
|
||||
libsaria::library::list_track(this);
|
||||
needs_cleanup = true;
|
||||
}
|
||||
|
||||
void Track::save(OutFile &out)
|
||||
|
|
Loading…
Reference in New Issue