libsaria: Bugfix Track playlist list
I was sometimes trying to remove a playlist from an invalid pointer. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
057bce8809
commit
ce6782558d
|
@ -27,8 +27,8 @@ namespace libsaria
|
||||||
{
|
{
|
||||||
length -= (*it)->get_length();
|
length -= (*it)->get_length();
|
||||||
index.remove_track(*it);
|
index.remove_track(*it);
|
||||||
it = plist.erase(it);
|
|
||||||
(*it)->rm_playlist(this);
|
(*it)->rm_playlist(this);
|
||||||
|
it = plist.erase(it);
|
||||||
RENDER( remove_index(rm_index) );
|
RENDER( remove_index(rm_index) );
|
||||||
if (rm_index != 0) {
|
if (rm_index != 0) {
|
||||||
rm_index--;
|
rm_index--;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// Copyright (c) 2012 Bryan Schumaker.
|
// Copyright (c) 2012 Bryan Schumaker.
|
||||||
#include <libsaria/index.h>
|
#include <libsaria/index.h>
|
||||||
|
#include <libsaria/track.h>
|
||||||
#include <libsaria/library.h>
|
#include <libsaria/library.h>
|
||||||
#include <libsaria/playlist.h>
|
#include <libsaria/playlist.h>
|
||||||
#include <libsaria/renderer.h>
|
#include <libsaria/renderer.h>
|
||||||
|
@ -49,6 +50,8 @@ namespace libsaria
|
||||||
|
|
||||||
void Playlist::prepare_for_removal()
|
void Playlist::prepare_for_removal()
|
||||||
{
|
{
|
||||||
|
list<libsaria::Track *>::iterator it;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I could do this in the destructor, but I think it could
|
* I could do this in the destructor, but I think it could
|
||||||
* lead to double-free errors with static playlists
|
* lead to double-free errors with static playlists
|
||||||
|
@ -60,6 +63,11 @@ namespace libsaria
|
||||||
renderer = NULL;
|
renderer = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove playlist from tracks */
|
||||||
|
for (it = plist.begin(); it != plist.end(); it++)
|
||||||
|
(*it)->rm_playlist(this);
|
||||||
|
|
||||||
rm_file();
|
rm_file();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,12 +213,12 @@ namespace libsaria
|
||||||
out << banned << "\n";
|
out << banned << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::add_playlist(libsaria::Playlist *plist)
|
void Track::add_playlist(Playlist *plist)
|
||||||
{
|
{
|
||||||
playlists.push_back(plist);
|
playlists.push_back(plist);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Track::rm_playlist(libsaria::Playlist *plist)
|
void Track::rm_playlist(Playlist *plist)
|
||||||
{
|
{
|
||||||
playlists.remove(plist);
|
playlists.remove(plist);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user