Make sure that there's always a description and content even if they're empty.

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@572797 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Scott Wheeler 2006-08-13 23:49:27 +00:00
parent 2f1645947a
commit 8e52873513
2 changed files with 16 additions and 9 deletions

View File

@ -165,7 +165,7 @@ UserTextIdentificationFrame::UserTextIdentificationFrame(String::Type encoding)
UserTextIdentificationFrame::UserTextIdentificationFrame(const ByteVector &data) :
TextIdentificationFrame(data)
{
checkFields();
}
String UserTextIdentificationFrame::toString() const
@ -182,14 +182,9 @@ String UserTextIdentificationFrame::description() const
StringList UserTextIdentificationFrame::fieldList() const
{
StringList l = TextIdentificationFrame::fieldList();
// TODO: remove this function
if(!l.isEmpty()) {
StringList::Iterator it = l.begin();
l.erase(it);
}
return l;
return TextIdentificationFrame::fieldList();
}
void UserTextIdentificationFrame::setText(const String &text)
@ -238,5 +233,15 @@ UserTextIdentificationFrame *UserTextIdentificationFrame::find(ID3v2::Tag *tag,
UserTextIdentificationFrame::UserTextIdentificationFrame(const ByteVector &data, Header *h) :
TextIdentificationFrame(data, h)
{
checkFields();
}
void UserTextIdentificationFrame::checkFields()
{
int fields = fieldList().size();
if(fields == 0)
setDescription(String::null);
if(fields <= 1)
setText(String::null);
}

View File

@ -232,6 +232,8 @@ namespace TagLib {
UserTextIdentificationFrame(const TextIdentificationFrame &);
UserTextIdentificationFrame &operator=(const UserTextIdentificationFrame &);
void checkFields();
class UserTextIdentificationFramePrivate;
UserTextIdentificationFramePrivate *d;
};