[Development] parented_ptr

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Thu Oct 16 10:25:13 CEST 2025


Hi,

Il 15/10/25 16:30, Daniel Schürmann ha scritto:
> Hello
> 
> My name is Daniel Schürmann and I am one of the core members in the 
> Mixxx team. We develop the QT based FOSS DJ software Mixxx.
> 
> Since a couple of years we use a custom smart pointer to wrap pointers 
> to QObjects, where the lifetime is managed by the QT object tree.
> 
> This is very useful for two reasons:
> * In reviews it is clear that there is no explicit delete required, it 
> eliminates the nowadays exceptional case of new() without delete().
> * The pointer asserts that the object has actually a parent and is not 
> leaked.
> 
> It has proven to be useful and disappointing that it is not available in 
> all my QT projects. That's why I like to discuss to put it or anything 
> similar into the QT source itself.
> 
> I have provided some more details in a QT bug here:
> https://bugreports.qt.io/browse/QTBUG-141134 <https://bugreports.qt.io/ 
> browse/QTBUG-141134>

Do you have an implementation that you could push as a WIP on gerrit? Or 
at least post it here as a skeleton?

(Note that we can't look at non-trivial implementations that aren't in 
the public domain, because we'd then taint our Qt contributions. 
Conversely, you shouldn't contribute under the CLA non-trivial 
implementations for which you don't have the rights...)

As far as I understand, parented_ptr would be a "smart" pointer that 
simply asserts that the managed object has a parent, and that's it? 
Does it do it just in the destructor or also in the other operations 
(dereferencing operators, .get(), etc.)?



Thank you,


-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - Trusted Software Excellence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4850 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/development/attachments/20251016/1b6855ff/attachment-0001.bin>


More information about the Development mailing list