db/LightSong: make Tag a reference

This enforces the "not nullptr" rule.
This commit is contained in:
Max Kellermann
2018-07-06 16:43:11 +02:00
parent ebc006ab52
commit b9ff6383a4
13 changed files with 23 additions and 26 deletions

View File

@@ -203,11 +203,11 @@ Copy(TagBuilder &tag, TagType d_tag,
}
ProxySong::ProxySong(const mpd_song *song)
:LightSong(tag2)
{
directory = nullptr;
uri = mpd_song_get_uri(song);
real_uri = nullptr;
tag = &tag2;
const auto _mtime = mpd_song_get_last_modified(song);
mtime = _mtime > 0

View File

@@ -98,12 +98,11 @@ Song::GetURI() const noexcept
LightSong
Song::Export() const noexcept
{
LightSong dest;
LightSong dest(tag);
dest.directory = parent->IsRoot()
? nullptr : parent->GetPath();
dest.uri = uri;
dest.real_uri = nullptr;
dest.tag = &tag;
dest.mtime = mtime;
dest.start_time = start_time;
dest.end_time = end_time;

View File

@@ -55,13 +55,13 @@ class UpnpSong : public LightSong {
public:
UpnpSong(UPnPDirObject &&object, std::string &&_uri)
:uri2(std::move(_uri)),
:LightSong(tag2),
uri2(std::move(_uri)),
real_uri2(std::move(object.url)),
tag2(std::move(object.tag)) {
directory = nullptr;
uri = uri2.c_str();
real_uri = real_uri2.c_str();
tag = &tag2;
mtime = std::chrono::system_clock::time_point::min();
start_time = end_time = SongTime::zero();
}
@@ -321,11 +321,10 @@ visitSong(const UPnPDirObject &meta, const char *path,
if (!visit_song)
return;
LightSong song;
LightSong song(meta.tag);
song.directory = nullptr;
song.uri = path;
song.real_uri = meta.url.c_str();
song.tag = &meta.tag;
song.mtime = std::chrono::system_clock::time_point::min();
song.start_time = song.end_time = SongTime::zero();