Thiago Macieira thiago at
Thu Jan 14 08:11:22 GMT 2010

Em Quinta-feira 14. Janeiro 2010, às 01.51.19, Maksim Orlovich escreveu:
> > the very first time i used QWeakPointer i gave a small groan about this.
> > by
> > the end of the day (was converting all the Plasma related code over to
> > this
> > and some other Qt 4.6 features) I was singing a very different tune. it
> > really
> > does help, doesn't add to the verbosity of the code in practice (store
> > and check the value of data() in a local var) and makes it very easy to
> > spot problem code.
> That's also a potential flaw: if you store it in local, and it goes away
> during that period, you wouldn't get a clean null-pointer crash.

No, you get a dangling-pointer dereference, which means valgrind will be more 

And the whole point is that you have to think whether the pointer will remain 
valid for the duration of your code. If your assumption breaks, then you have 
a problem.

Thiago Macieira - thiago (AT) - thiago (AT)
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the kde-core-devel mailing list