TagLib 1.7 reporting tags always present

Gregorio Guidi gregorio.guidi at gmail.com
Fri Jan 20 20:43:45 UTC 2012


Hi all,

I noticed that if you compile this simple code against TagLib 1.7, to 
test if tags are present:

#include <iostream>
#include <mpegfile.h>
int main(int argc, char *argv[])
{
   TagLib::MPEG::File f(argv[1]);
   TagLib::ID3v2::Tag *tag2 = f.ID3v2Tag();
   if (tag2) {
     std::cout << "ID3v2 tag is present." << std::endl;
   }
   TagLib::ID3v1::Tag *tag1 = f.ID3v1Tag();
   if (tag1) {
     std::cout << "ID3v1 tag is present." << std::endl;
   }

   return 0;
}

... then you always get the result "ID3v2 tag is present" and "ID3v1 tag 
is present" for any file irrespective of actual content, in contrast to 
the API docs for the ID3v2Tag()/ID3v1Tag() methods.

The following patch shows where the problem lies. By removing those 
lines you get correct behavior, but of course I imagine there was a 
reason for them being added there and I am not sure if it is ok to just 
remove them...

Bye.
Gregorio


diff -Nur taglib-1.7.orig/taglib/mpeg/mpegfile.cpp 
taglib-1.7/taglib/mpeg/mpegfile.cpp
--- taglib-1.7.orig/taglib/mpeg/mpegfile.cpp    2011-03-11 
14:15:38.000000000 +0100
+++ taglib-1.7/taglib/mpeg/mpegfile.cpp 2012-01-20 21:30:21.469425159 +0100
@@ -430,11 +430,6 @@

    if(readProperties)
      d->properties = new Properties(this, propertiesStyle);
-
-  // Make sure that we have our default tag types available.
-
-  ID3v2Tag(true);
-  ID3v1Tag(true);
  }

  long MPEG::File::findID3v2()


More information about the taglib-devel mailing list