[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: SmartPointerList
From:       Thiago Macieira <thiago () kde ! org>
Date:       2010-01-14 8:11:22
Message-ID: 201001140911.40648.thiago () kde ! org
[Download RAW message or body]


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 
helpful.

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) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic