]> granicus.if.org Git - taglib/commitdiff
Fix issue #88 by changing the behavior of setProperties().
authorMichael Helmling <helmling@mathematik.uni-kl.de>
Mon, 10 Dec 2012 19:56:16 +0000 (20:56 +0100)
committerMichael Helmling <helmling@mathematik.uni-kl.de>
Mon, 10 Dec 2012 19:56:16 +0000 (20:56 +0100)
For file types that support multiple tag standards (for example, FLAC
files can have ID3v1, ID3v2, and Vorbis comments) setProperties is now
called for all existing tags instead of only for the most recommended
one.
This fixes the problem that under some circumstances it was not possible
to delete a value using setProperties() because upon save() the call to
Tag::duplicate recovered that value from the ID3v1 tag.

taglib/ape/apefile.cpp
taglib/flac/flacfile.cpp
taglib/mpc/mpcfile.cpp
taglib/mpeg/mpegfile.cpp
taglib/trueaudio/trueaudiofile.cpp
taglib/wavpack/wavpackfile.cpp

index 2572a2e95e294f0676d6d2d5ae4fb5453cf20c2c..fae4ab033cddb881c0d14431edd236dc2241268b 100644 (file)
@@ -131,12 +131,12 @@ void APE::File::removeUnsupportedProperties(const StringList &properties)
 
 PropertyMap APE::File::setProperties(const PropertyMap &properties)
 {
-  if(d->hasAPE)
-    return d->tag.access<APE::Tag>(ApeAPEIndex, false)->setProperties(properties);
-  else if(d->hasID3v1)
-    return d->tag.access<ID3v1::Tag>(ApeID3v1Index, false)->setProperties(properties);
-  else
-    return d->tag.access<APE::Tag>(ApeAPEIndex, true)->setProperties(properties);
+  PropertyMap result;
+  if(d->hasID3v1)
+    result = d->tag.access<ID3v1::Tag>(ApeID3v1Index, false)->setProperties(properties);
+  if(d->hasAPE || !d->hasID3v1)
+    result = d->tag.access<APE::Tag>(ApeAPEIndex, true)->setProperties(properties);
+  return result;
 }
 
 APE::Properties *APE::File::audioProperties() const
index 0bfe84c3a7ee07c0861fa92b4243856ee7da6aa2..26d799747b6a344bc68800f20922a8ec712f9551 100644 (file)
@@ -168,14 +168,14 @@ void FLAC::File::removeUnsupportedProperties(const StringList &unsupported)
 
 PropertyMap FLAC::File::setProperties(const PropertyMap &properties)
 {
-  if(d->hasXiphComment)
-    return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, false)->setProperties(properties);
-  else if(d->hasID3v2)
-    return d->tag.access<ID3v2::Tag>(FlacID3v2Index, false)->setProperties(properties);
-  else if(d->hasID3v1)
-    return d->tag.access<ID3v1::Tag>(FlacID3v1Index, false)->setProperties(properties);
-  else
-    return d->tag.access<Ogg::XiphComment>(FlacXiphIndex, true)->setProperties(properties);
+  PropertyMap result;
+  if(d->hasID3v1)
+      result = d->tag.access<ID3v1::Tag>(FlacID3v1Index, false)->setProperties(properties);
+  if(d->hasID3v2)
+      result = d->tag.access<ID3v2::Tag>(FlacID3v2Index, false)->setProperties(properties);
+  if(d->hasXiphComment || !(d->hasID3v1 || d->hasID3v2))
+    result = d->tag.access<Ogg::XiphComment>(FlacXiphIndex, true)->setProperties(properties);
+  return result;
 }
 
 FLAC::Properties *FLAC::File::audioProperties() const
index 18f533f8845b3691912f7baad6cd48df479fb56e..6d6b3f6bef8ca03d4718d4bf3a8d5383930207b7 100644 (file)
@@ -135,15 +135,14 @@ void MPC::File::removeUnsupportedProperties(const StringList &properties)
 
 PropertyMap MPC::File::setProperties(const PropertyMap &properties)
 {
-  if(d->hasAPE)
-    return d->tag.access<APE::Tag>(MPCAPEIndex, false)->setProperties(properties);
-  else if(d->hasID3v1)
-    return d->tag.access<ID3v1::Tag>(MPCID3v1Index, false)->setProperties(properties);
-  else
-    return d->tag.access<APE::Tag>(APE, true)->setProperties(properties);
+  PropertyMap result;
+  if(d->hasID3v1)
+    result = d->tag.access<ID3v1::Tag>(MPCID3v1Index, false)->setProperties(properties);
+  if(d->hasAPE || !d->hasID3v1)
+    result = d->tag.access<APE::Tag>(MPCAPEIndex, true)->setProperties(properties);
+  return result;
 }
 
-
 MPC::Properties *MPC::File::audioProperties() const
 {
   return d->properties;
index ec094cdc3098dedb45033d42286543df405f7fa0..907540076b1d4a15905a15ae65b88aaf24e9e8ff 100644 (file)
@@ -156,16 +156,17 @@ void MPEG::File::removeUnsupportedProperties(const StringList &properties)
   else if(d->hasID3v1)
     d->tag.access<ID3v1::Tag>(ID3v1Index, false)->removeUnsupportedProperties(properties);
 }
+
 PropertyMap MPEG::File::setProperties(const PropertyMap &properties)
 {
-  if(d->hasID3v2)
-    return d->tag.access<ID3v2::Tag>(ID3v2Index, false)->setProperties(properties);
-  else if(d->hasAPE)
-    return d->tag.access<APE::Tag>(APEIndex, false)->setProperties(properties);
-  else if(d->hasID3v1)
-    return d->tag.access<ID3v1::Tag>(ID3v1Index, false)->setProperties(properties);
-  else
-    return d->tag.access<ID3v2::Tag>(ID3v2Index, true)->setProperties(properties);
+  PropertyMap result;
+  if(d->hasID3v1)
+      result = d->tag.access<ID3v1::Tag>(ID3v1Index, false)->setProperties(properties);
+  if(d->hasAPE)
+      result = d->tag.access<APE::Tag>(APEIndex, false)->setProperties(properties);
+  if(d->hasID3v2 || !(d->hasID3v1 || d->hasAPE))
+    result = d->tag.access<ID3v2::Tag>(ID3v2Index, true)->setProperties(properties);
+  return result;
 }
 
 MPEG::Properties *MPEG::File::audioProperties() const
index 9efc6e9def7cd5840cfec9450e736f25bd9482b0..6af72aaa7d74921e34869cd61e10605ffc17e55d 100644 (file)
@@ -141,12 +141,12 @@ PropertyMap TrueAudio::File::properties() const
 
 PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties)
 {
-  if(d->hasID3v2)
-    return d->tag.access<ID3v2::Tag>(TrueAudioID3v2Index, false)->setProperties(properties);
-  else if(d->hasID3v1)
-    return d->tag.access<ID3v1::Tag>(TrueAudioID3v1Index, false)->setProperties(properties);
-  else
-    return d->tag.access<ID3v2::Tag>(TrueAudioID3v2Index, true)->setProperties(properties);
+  PropertyMap result;
+  if(d->hasID3v1)
+    result = d->tag.access<ID3v1::Tag>(TrueAudioID3v1Index, false)->setProperties(properties);
+  if(d->hasID3v2 || !d->hasID3v1)
+    result =d->tag.access<ID3v2::Tag>(TrueAudioID3v2Index, true)->setProperties(properties);
+  return result;
 }
 
 TrueAudio::Properties *TrueAudio::File::audioProperties() const
index 2d1f8cd9271e153ad0220e6bb0ec55755aa7ca97..6cc86527bdfcdd9f33dc254d40d175bddc3f457b 100644 (file)
@@ -119,12 +119,12 @@ PropertyMap WavPack::File::properties() const
 
 PropertyMap WavPack::File::setProperties(const PropertyMap &properties)
 {
-  if(d->hasAPE)
-    return d->tag.access<APE::Tag>(WavAPEIndex, false)->setProperties(properties);
-  else if(d->hasID3v1)
-    return d->tag.access<ID3v1::Tag>(WavID3v1Index, false)->setProperties(properties);
-  else
-    return d->tag.access<APE::Tag>(APE, true)->setProperties(properties);
+  PropertyMap result;
+  if(d->hasID3v1)
+    result = d->tag.access<ID3v1::Tag>(WavID3v1Index, false)->setProperties(properties);
+  if(d->hasAPE || !d->hasID3v1)
+    result = d->tag.access<APE::Tag>(WavAPEIndex, true)->setProperties(properties);
+  return result;
 }
 
 WavPack::Properties *WavPack::File::audioProperties() const