libsaria: Change track cleanup process
Tracks only need to be unlisted from the library list when they are manually removed by the user. Trying to do this during shutdown lead do a segfault because the library's file_list had already been removed when I tried to access it.
This commit is contained in:
parent
2a9900c1e5
commit
ab0e459298
|
@ -42,6 +42,7 @@ namespace libsaria
|
|||
Track(InFile &);
|
||||
~Track();
|
||||
void save(OutFile &);
|
||||
void do_cleanup();
|
||||
|
||||
string get_filepath();
|
||||
string get_title();
|
||||
|
|
|
@ -54,6 +54,7 @@ namespace libsaria
|
|||
|
||||
for (it = path_list.begin(); it != path_list.end(); it++) {
|
||||
if (it->get_path() == dir) {
|
||||
it->prepare_for_removal();
|
||||
path_list.erase(it);
|
||||
save();
|
||||
refresh();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <list>
|
||||
using namespace std;
|
||||
|
||||
list<libsaria::Track *>::iterator it;
|
||||
static list<libsaria::Track *>::iterator it;
|
||||
|
||||
namespace libsaria
|
||||
{
|
||||
|
|
|
@ -17,7 +17,14 @@ LibraryPath::~LibraryPath()
|
|||
{
|
||||
list<libsaria::Track *>::iterator it;
|
||||
for (it = file_list.begin(); it != file_list.end(); it++)
|
||||
delete *it;
|
||||
delete (*it);
|
||||
}
|
||||
|
||||
void LibraryPath::prepare_for_removal()
|
||||
{
|
||||
list<libsaria::Track *>::iterator it;
|
||||
for (it = file_list.begin(); it != file_list.end(); it++)
|
||||
(*it)->do_cleanup();
|
||||
}
|
||||
|
||||
string LibraryPath::get_path()
|
||||
|
|
|
@ -22,6 +22,7 @@ class LibraryPath
|
|||
|
||||
void load_file(InFile &, string);
|
||||
string get_path();
|
||||
void prepare_for_removal();
|
||||
void get_info(void (*)(struct libsaria::library::PathInfo &));
|
||||
void add_track(string &, sid_t &);
|
||||
void save(OutFile &);
|
||||
|
|
|
@ -68,10 +68,11 @@ namespace libsaria
|
|||
do_bookkeeping();
|
||||
}
|
||||
|
||||
Track::~Track()
|
||||
Track::~Track() {}
|
||||
|
||||
void Track::do_cleanup()
|
||||
{
|
||||
if (needs_cleanup)
|
||||
libsaria::library::unlist_track(this);
|
||||
libsaria::library::unlist_track(this);
|
||||
}
|
||||
|
||||
void Track::do_bookkeeping()
|
||||
|
|
Loading…
Reference in New Issue