DRAFT document on coding conventions in kde libraries

Thiago Macieira thiago at kde.org
Mon Mar 6 09:36:24 GMT 2006


Sandro Giessl wrote:
>On Sunday 05 March 2006 14:45, Thiago Macieira wrote:
>> - all reference count variables should use QAtomic: do not implement
>> your own refcounting mechanism using "int".
>
>BTW. I can't find anything about QAtomic in Qt 4.1 docs (though, I
> believe I have read about it in a Qt Quarterly or so). Any hints where
> to find it?

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);

(qAtomicAssign is documented)

-- 
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

1. On frumscafte, hwonne time_t wæs náht, se scieppend þone circolwyrde 
wundorcræftlíge cennede and seo eorðe wæs idel and hit wæs gód.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060306/36c76b4e/attachment.sig>


More information about the kde-core-devel mailing list