Fwd: Unusual behaviour of taglib using threads.

Sergey Vlasov vsu at altlinux.ru
Wed May 2 19:53:08 CEST 2007


On Wed, May 02, 2007 at 09:28:07PM +0530, Yogesh M wrote:
> I think things like RefCounter should not be of any problem because
> I'm not sharing same taglib object(s) in two threads. In that sense
> usage of String and ByteVector should be ok, right?

The problem is caused by methods like:

String ID3v2::Tag::title() const
{
  if(!d->frameListMap["TIT2"].isEmpty())
    return d->frameListMap["TIT2"].front()->toString();
  return String::null;
}

When this method returns String::null, a copy constructor of
TagLib::String is called, which increments the refcount of the
StringPrivate object belonging to String::null - the same object for
all threads.  So even if you do not share TagLib objects yourself,
some objects are shared implicitly.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.kde.org/pipermail/taglib-devel/attachments/20070502/5e04403f/attachment.pgp 


More information about the taglib-devel mailing list