mirror of
https://github.com/taglib/taglib.git
synced 2025-07-19 05:24:25 -04:00
MP4: Remove item when empty string is set (#929)
This will make the behavior for MP4 tags compliant to the API documentation and consistent with other tag formats.
This commit is contained in:
@ -775,31 +775,41 @@ MP4::Tag::track() const
|
||||
void
|
||||
MP4::Tag::setTitle(const String &value)
|
||||
{
|
||||
d->items["\251nam"] = StringList(value);
|
||||
setTextItem("\251nam", value);
|
||||
}
|
||||
|
||||
void
|
||||
MP4::Tag::setArtist(const String &value)
|
||||
{
|
||||
d->items["\251ART"] = StringList(value);
|
||||
setTextItem("\251ART", value);
|
||||
}
|
||||
|
||||
void
|
||||
MP4::Tag::setAlbum(const String &value)
|
||||
{
|
||||
d->items["\251alb"] = StringList(value);
|
||||
setTextItem("\251alb", value);
|
||||
}
|
||||
|
||||
void
|
||||
MP4::Tag::setComment(const String &value)
|
||||
{
|
||||
d->items["\251cmt"] = StringList(value);
|
||||
setTextItem("\251cmt", value);
|
||||
}
|
||||
|
||||
void
|
||||
MP4::Tag::setGenre(const String &value)
|
||||
{
|
||||
d->items["\251gen"] = StringList(value);
|
||||
setTextItem("\251gen", value);
|
||||
}
|
||||
|
||||
void
|
||||
MP4::Tag::setTextItem(const String &key, const String &value)
|
||||
{
|
||||
if (!value.isEmpty()) {
|
||||
d->items[key] = StringList(value);
|
||||
} else {
|
||||
d->items.erase(key);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -106,6 +106,13 @@ namespace TagLib {
|
||||
void removeUnsupportedProperties(const StringList& properties);
|
||||
PropertyMap setProperties(const PropertyMap &properties);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* Sets the value of \a key to \a value, overwriting any previous value.
|
||||
* If \a value is empty, the item is removed.
|
||||
*/
|
||||
void setTextItem(const String &key, const String &value);
|
||||
|
||||
private:
|
||||
AtomDataList parseData2(const Atom *atom, int expectedFlags = -1,
|
||||
bool freeForm = false);
|
||||
|
Reference in New Issue
Block a user