[Qt-interest] changes of QByteArray in 4.4.0

Bradley T. Hughes bradley.hughes at nokia.com
Thu Apr 16 12:47:05 CEST 2009


Markus.Klinik at elektrobit.com wrote:
> Hi!
> 
> There was a change in QByteArray (src/corelib/tools/qbytearray.cpp) in the
> transition from release 4.3.5 to 4.4.0 that produces diffs like this, or
> similar, at several places in that file:
> 
> -    x = qAtomicSetPtr(&d, x);
> -    if (!x->ref.deref())
> -         qFree(x);
> +    if (!d->ref.deref())
> +         qFree(d);
> +    d = x;
> 
> It looks like a race condition was sorted out, because the pointer assignment
> was moved to the end.
> 
> Does somebody remember what the problem was? I can't find anything on the
> mailing list, in the task tracker or in the Changelog.

This is an optimization change that was done in all of our implicitly shared 
classes to avoid the unnecessary atomic fetch-and-store. Only the reference 
count needs to be updated atomically, not the d-pointer itself.

-- 
Bradley T. Hughes (Nokia-D-Qt/Oslo), bradley.hughes at nokia.com
Sandakervn. 116, P.O. Box 4332 Nydalen, 0402 Oslo, Norway



More information about the Qt-interest-old mailing list