Iterating through and removing Frames

Michael Helmling helmling at mathematik.uni-kl.de
Tue Dec 4 08:01:21 UTC 2012


Hi Festus,

you are right about the iterator getting invalid. You should use 
something like:

ID3v2::FrameList toRemove;
for(....)
     if(...)
         toRemove.append(it);

And then:
for(ID3v2::FrameList::ConstIterator it = toRemove.begin(); ....)
     id3v2tag->removeFrame(*it);

That construct is used on several places in the unified string key API 
of taglib.

Regards,
Michael
Am 04.12.2012 07:52, schrieb Festus Hagen:
> Hi all,
>
> I have been searching for an example or info leading to the correct method to do the following with out success.
> (hopefully it's readable)
>
>              for(ID3v2::FrameList::ConstIterator it = id3v2tag->frameList().begin();
>                      it != id3v2tag->frameList().end(); it++) {
>                  if (    (*it)->frameID() != "TIT2"
>                       && (*it)->frameID() != "TPE1"
>                       && (*it)->frameID() != "TALB"
>                       && (*it)->frameID() != "TRCK"
>                       ) {
>                      id3v2tag->removeFrames((*it)->frameID());
>                      bSave = true;
>                  }
>              }
>              if (bSave)
>              f.save(MPEG::File::ID3v2);
>
> Obviously it doesn't work.
> Could someone please give me a kick in the right direction.
>
> I believe I understand whats wrong, I just don't know how to overcome it.
> The iterator gets invalidated when a frame(s) is deleted ??
>
> Thanks
> fh : )_~
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: helmling.vcf
Type: text/x-vcard
Size: 352 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/taglib-devel/attachments/20121204/e4b42058/attachment.vcf>


More information about the taglib-devel mailing list