[Development] Deleter that calls deleteLater() for use with std::unique_ptr<> and other smart pointers

Konstantin Tokarev annulen at yandex.ru
Wed Apr 19 16:56:31 CEST 2017



19.04.2017, 17:52, "Giuseppe D'Angelo" <giuseppe.dangelo at kdab.com>:
> Il 19/04/2017 15:44, Konstantin Tokarev ha scritto:
>>  I think it will be a good idea to provide implementation of functor calling
>>  deleteLater() instead of delete which can be used with std::unique_ptr,
>>  std::shared_ptr and other smart pointers with compatible interface.
>>
>>  We already have QScopedPointerObjectDeleteLater, however it implements
>>  cleanup(T*) instead of operator()(T*).
>>
>>  Any suggestions how to name this new class and where to place it?
>
> Where to place it: in qobject.h, unless we claim this is done for STL
> compatibility, and therefore it may need to go somewhere else depending
> on the resolution on the other thread.
>
> I don't think this stuff should be there purely for STL compatibility.
> In hindsight, the QScopedPointer deleters should have had more generic
> names than QScopedPointerFoo, as they should be usable in other
> scenarios too (QSharedPointer?).
>
> So, maybe, just add this as an inner class of QObject?
> QObject::DeleteLater(Functor) maybe?

I thought about it, however I had a concern that QScopedPointerObjectDeleteLater
is a template that in theory can call non-QObject deleteLater() method, while
inner class of QObject is expected to work with QObject-derived classes only

>
> My 2 cents,
> --
> Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
> KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
> KDAB - Qt, C++ and OpenGL Experts
>
> ,
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

-- 
Regards,
Konstantin



More information about the Development mailing list