qt5base-lts/tests/auto/corelib/tools
Jøger Hansegård 8d367dec15 Add QUniqueHandle - a general purpose RAII wrapper for non-memory types
When interfacing with C-style APIs, such as the Windows API, resources
are often represented using handle objects. Lifetime management of such
resources can be cumbersome and error prone, because typical handle
objects (ints) do not give any help to release resources, and to manage
ownership.

Although std::unique_ptr can be retro-fitted with a custom deleter, and
helps transfer of ownership, it is inherently a pointer type. It can
therefore be clumsy to use with C-style APIs, particularly if the
invalid (uninitialized) handle value is not a nullptr. Also, the
std::unique_ptr does not work well when an allocating function returns
the handle as a pointer argument.

The QUniqueHandle addresses these issues by providing a movable only
value type that is designed as a RAII handle wrapper.

A similar handle wrapper exists in the Windows SDK, as part of the WRL
library. Unfortunately, this is Microsoft specific, and is not supported
by MINGW.

Since the QUniqueHandle is platform independent, it can be used also
with non- Microsoft platforms, and can be useful with other C-style APIs
such as FFmpeg or SQLite.

Pick-to: 6.6 6.5
Change-Id: Ibfc0cec3f361ec004febea5f284ebf75e27c0054
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-15 05:01:51 +01:00
..
collections Mark all of Qt as free of Q_FOREACH, except where it isn't 2023-08-19 05:19:42 +00:00
containerapisymmetry CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qalgorithms CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qarraydata QArrayDataPointer: add an allocating constructor 2023-10-25 12:01:58 -07:00
qatomicscopedvaluerollback QAtomicScopedValueRollback: fix CTAD for Q(Basic)AtomicPointer 2023-07-12 10:29:44 +02:00
qbitarray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qcache CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qcommandlineparser QCommandLineParser: Warn invalid value calls 2023-09-21 22:05:06 +02:00
qcontiguouscache CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qcryptographichash QCryptographicHash: fallback to non-OpenSSL implementation for Keccak 2023-11-08 18:40:14 +01:00
qduplicatetracker CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qeasingcurve tests/auto/: port Q_FOREACH to ranged-for, local const containers 2023-08-19 16:29:25 +03:00
qexplicitlyshareddatapointer tst_QExplicitlySharedDataPointer: Remove stray comment 2023-07-25 12:31:04 +02:00
qflatmap CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qfreelist tst_QFreeList: build with QT_NO_FOREACH 2023-08-19 16:29:54 +03:00
qhash CMake: remove check for cxx11_future 2023-08-02 12:36:18 -07:00
qhashfunctions tst_QHashFunctions: suppress warning about casting from float to _Float16 2023-10-24 08:44:36 -07:00
qhashseed CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qline CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qlist QArrayDataPointer: remove Q_CHECK_PTR in assign(it, it) again 2023-09-07 15:05:05 +02:00
qmacautoreleasepool CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmakearray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmap CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmargins CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qmessageauthenticationcode CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qoffsetstringarray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qpair CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qpoint CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qpointf CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qqueue CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qrect CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qringbuffer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qscopedpointer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qscopedvaluerollback CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qscopeguard tst_QScopeGuard: test if and how guard in optional<> works 2023-07-10 19:47:08 +00:00
qset CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qsharedpointer QSP/QWP: introduce owner_before, owner_equal, owner_hash 2023-10-26 19:24:40 +02:00
qsize CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qsizef CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qspan QSpan: add C++23 c{,r}{begin,end}() 2023-10-12 21:38:54 +02:00
qstl CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qtaggedpointer CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qtimeline CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
quniquehandle Add QUniqueHandle - a general purpose RAII wrapper for non-memory types 2023-11-15 05:01:51 +01:00
qvarlengtharray CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
qversionnumber CMake: Make corelib tests standalone projects 2023-07-05 15:09:32 +02:00
CMakeLists.txt Add QUniqueHandle - a general purpose RAII wrapper for non-memory types 2023-11-15 05:01:51 +01:00