Prefer COMM frames with no description for setComment()

This creates symetry with ID3v2::Tag::comment() in preferring frames with no description
when choosing which COMM frame should be updated.  (Previously setComment() simply updated
the first COMM frame.)

Fixes #950
This commit is contained in:
Scott Wheeler
2020-03-27 12:13:12 +01:00
parent 54508df30b
commit 47342f6974
3 changed files with 28 additions and 8 deletions

View File

@ -250,13 +250,24 @@ void ID3v2::Tag::setComment(const String &s)
return;
}
if(!d->frameListMap["COMM"].isEmpty())
d->frameListMap["COMM"].front()->setText(s);
else {
CommentsFrame *f = new CommentsFrame(d->factory->defaultTextEncoding());
addFrame(f);
f->setText(s);
const FrameList &comments = d->frameListMap["COMM"];
if(!comments.isEmpty()) {
for(FrameList::ConstIterator it = comments.begin(); it != comments.end(); ++it) {
CommentsFrame *frame = dynamic_cast<CommentsFrame *>(*it);
if(frame && frame->description().isEmpty()) {
(*it)->setText(s);
return;
}
}
comments.front()->setText(s);
return;
}
CommentsFrame *f = new CommentsFrame(d->factory->defaultTextEncoding());
addFrame(f);
f->setText(s);
}
void ID3v2::Tag::setGenre(const String &s)