]> granicus.if.org Git - taglib/commitdiff
Make sure that there's always a description and content even if they're empty.
authorScott Wheeler <wheeler@kde.org>
Sun, 13 Aug 2006 23:49:27 +0000 (23:49 +0000)
committerScott Wheeler <wheeler@kde.org>
Sun, 13 Aug 2006 23:49:27 +0000 (23:49 +0000)
git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@572797 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

mpeg/id3v2/frames/textidentificationframe.cpp
mpeg/id3v2/frames/textidentificationframe.h

index c4bb339a0cb6ec3d6cd5b8649cb90b5e2e531284..d2cebc12608a12f7b3d6085c9d2240a9d23d53c5 100644 (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();
-
-  if(!l.isEmpty()) {
-    StringList::Iterator it = l.begin();
-    l.erase(it);
-  }
+  // TODO: remove this function
 
-  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);
 }
index 00c13851efc3af8f142c19d6f05be8b387069550..48b5bd55d0fa8b3d9f4633948ea4587f58d56527 100644 (file)
@@ -232,6 +232,8 @@ namespace TagLib {
       UserTextIdentificationFrame(const TextIdentificationFrame &);
       UserTextIdentificationFrame &operator=(const UserTextIdentificationFrame &);
 
+      void checkFields();
+
       class UserTextIdentificationFramePrivate;
       UserTextIdentificationFramePrivate *d;
     };