DRAFT document on coding conventions in kde libraries

Kuba Ober kuba at mareimbrium.org
Mon Mar 6 13:56:19 GMT 2006


> >> - all reference count variables should use QAtomic: do not implement
> >> your own refcounting mechanism using "int".
. . .
> Hmm... indeed, the class is not documented. I'll take a look why that is
> so.
>
> Basically, what you want is:
>
> - in your Private class:
>   QAtomic ref;
> - in your constructor:
>   d->ref.ref();
> - in your destructor:
>   if (!d->ref.deref())
>     delete d;
>
> - in your assignment operator:
>   qAtomicAssign(d, other.d);

QAtomic does not implement a copy constructor and operator= that
would do the right thing?! Maybe then one should have KAtomic that
would be more sane to use . . . Is there a good reason for QAtomic
to be broken like that (if that's indeed the case)?

Cheers, Kuba




More information about the kde-core-devel mailing list