aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-18 21:51:45 +0100
committerMax Kellermann <max@duempel.org>2008-11-18 21:51:45 +0100
commitebb9e5b1924e6bc5baaae9ced82b54be586f6b74 (patch)
treee295a76f8aeab0d4c697def510130dd8c163e9d4
parenta094e912687b2e1078ee2808a049f94b15325b79 (diff)
downloadmpd-ebb9e5b1924e6bc5baaae9ced82b54be586f6b74.tar.gz
mpd-ebb9e5b1924e6bc5baaae9ced82b54be586f6b74.tar.xz
mpd-ebb9e5b1924e6bc5baaae9ced82b54be586f6b74.zip
screen_lyrics: duplicate current song
Don't store a pointer to the song passed to screen_lyrics_switch(), duplicate it instead. In the long term, it is too unsafe to work with a foreign pointer.
-rw-r--r--src/screen_lyrics.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index f98e6692b..ab9dfdeda 100644
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
@@ -41,7 +41,7 @@ static list_window_t *lw = NULL;
static const struct mpd_song *next_song;
static struct {
- const struct mpd_song *song;
+ struct mpd_song *song;
char *artist, *title;
@@ -68,7 +68,10 @@ screen_lyrics_abort(void)
current.artist = NULL;
}
- current.song = NULL;
+ if (current.song != NULL) {
+ mpd_freeSong(current.song);
+ current.song = NULL;
+ }
}
static void
@@ -175,7 +178,7 @@ screen_lyrics_load(const struct mpd_song *song)
screen_lyrics_abort();
screen_lyrics_clear();
- current.song = song;
+ current.song = mpd_songDup(song);
strfsong(buffer, sizeof(buffer), "%artist%", song);
current.artist = g_strdup(buffer);
@@ -268,7 +271,9 @@ lyrics_open(mpdclient_t *c)
if (next_song == NULL)
next_song = c->song;
- if (next_song != NULL && next_song != current.song)
+ if (next_song != NULL &&
+ (current.song == NULL ||
+ strcmp(next_song->file, current.song->file) != 0))
screen_lyrics_load(next_song);
next_song = NULL;