[Development] unique_ptr and Qt, Take 2

Thiago Macieira thiago.macieira at intel.com
Fri May 3 21:40:14 CEST 2019


On Friday, 3 May 2019 12:32:01 PDT Allan Sandfeld Jensen wrote:
> Alternatively QObjects should be referenced counted, one reference could be
> from a parent, but you could also strong reference with an explicit shared
> pointer.

The problem with that is that you can create QObjects on the stack and those 
mustn't be refcounted.

That said, the QPointer mechanism since 5.0 is basically refcounting, 
Technically, it's a refcounted refcounter. Since it shares the same class as 
QSharedPointer, it *has* the strong refcount inside, which could be used for 
this.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products





More information about the Development mailing list