From 8e528735137f12032e2a95a86c52eab9374bb076 Mon Sep 17 00:00:00 2001 From: Scott Wheeler Date: Sun, 13 Aug 2006 23:49:27 +0000 Subject: [PATCH] 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 --- mpeg/id3v2/frames/textidentificationframe.cpp | 23 +++++++++++-------- mpeg/id3v2/frames/textidentificationframe.h | 2 ++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/mpeg/id3v2/frames/textidentificationframe.cpp b/mpeg/id3v2/frames/textidentificationframe.cpp index c4bb339a..d2cebc12 100644 --- a/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/mpeg/id3v2/frames/textidentificationframe.cpp @@ -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); } diff --git a/mpeg/id3v2/frames/textidentificationframe.h b/mpeg/id3v2/frames/textidentificationframe.h index 00c13851..48b5bd55 100644 --- a/mpeg/id3v2/frames/textidentificationframe.h +++ b/mpeg/id3v2/frames/textidentificationframe.h @@ -232,6 +232,8 @@ namespace TagLib { UserTextIdentificationFrame(const TextIdentificationFrame &); UserTextIdentificationFrame &operator=(const UserTextIdentificationFrame &); + void checkFields(); + class UserTextIdentificationFramePrivate; UserTextIdentificationFramePrivate *d; };