[Development] The future of smart pointers in Qt API

Vitaly Fanaskov vitaly.fanaskov at qt.io
Tue Feb 4 14:26:46 CET 2020


I think that this case might be handled by using a smart pointer with a custom empty deleter. In this case we have absolutely the same potential issues as with a raw pointer to a stack object. Strictly speaking, something like that requires a great care and I'd recommend avoiding such approach.

On 2/4/20 1:22 PM, Konstantin Shegunov wrote:
On Tue, Feb 4, 2020 at 12:15 PM Vitaly Fanaskov <vitaly.fanaskov at qt.io<mailto:vitaly.fanaskov at qt.io>> wrote:
I think, if we decide to re-implement parent-child model using smart
pointers, we would not use unique pointers at all. Even in a methods
like QObject::makeChild (because ownership is already defined). Shared +
weak pointers make perfect sense here.

You have to be really crafty. Allocating on the stack is a thing, you know, even for parent-child trees, so how do you intend to handle that? Are we again in "forget the stack and new everything" land?

--
Best Regards,

Fanaskov Vitaly
Senior Software Engineer

The Qt Company / Qt Quick and Widgets Team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20200204/9cd80c7f/attachment.html>


More information about the Development mailing list