aboutsummaryrefslogtreecommitdiffstats
path: root/src/PlaylistTag.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-12-03 12:56:36 +0100
committerMax Kellermann <max@duempel.org>2013-12-03 12:59:55 +0100
commit9f4e96fdfa0967fa83444a44c8e6fdbda14b96c3 (patch)
tree2f08a42a9c2f70160e892314dbeaf3bf559a8203 /src/PlaylistTag.cxx
parentc36af357303891a45fdcb286b99ca8bb5be20693 (diff)
downloadmpd-9f4e96fdfa0967fa83444a44c8e6fdbda14b96c3.tar.gz
mpd-9f4e96fdfa0967fa83444a44c8e6fdbda14b96c3.tar.xz
mpd-9f4e96fdfa0967fa83444a44c8e6fdbda14b96c3.zip
PaylistTag: use class TagBuilder
Diffstat (limited to 'src/PlaylistTag.cxx')
-rw-r--r--src/PlaylistTag.cxx22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/PlaylistTag.cxx b/src/PlaylistTag.cxx
index 5813ec1c1..e158018f5 100644
--- a/src/PlaylistTag.cxx
+++ b/src/PlaylistTag.cxx
@@ -28,6 +28,7 @@
#include "PlaylistError.hxx"
#include "Song.hxx"
#include "tag/Tag.hxx"
+#include "tag/TagBuilder.hxx"
#include "util/Error.hxx"
bool
@@ -48,9 +49,15 @@ playlist::AddSongIdTag(unsigned id, TagType tag_type, const char *value,
return false;
}
- if (song.tag == nullptr)
- song.tag = new Tag();
- song.tag->AddItem(tag_type, value);
+ TagBuilder tag;
+ if (song.tag != nullptr) {
+ tag = std::move(*song.tag);
+ delete song.tag;
+ }
+
+ tag.AddItem(tag_type, value);
+ song.tag = tag.Commit();
+
queue.ModifyAtPosition(position);
OnModified();
return true;
@@ -77,10 +84,15 @@ playlist::ClearSongIdTag(unsigned id, TagType tag_type,
if (song.tag == nullptr)
return true;
+ TagBuilder tag(std::move(*song.tag));
+ delete song.tag;
+
if (tag_type == TAG_NUM_OF_ITEM_TYPES)
- song.tag->RemoveAll();
+ tag.RemoveAll();
else
- song.tag->RemoveType(tag_type);
+ tag.RemoveType(tag_type);
+ song.tag = tag.Commit();
+
queue.ModifyAtPosition(position);
OnModified();
return true;