Add missing noexcept specifiers for QUniqueHandle handle traits
Handle traits should be simple, and not require exceptions. This patch will allow us to improve the noexcept correctness of QUniqueHandle. Pick-to: 6.8 Change-Id: I84d92818a2fcea5b98e09c0b7dc08b251751396c Reviewed-by: Tim Blechmann <tim.blechmann@qt.io> (cherry picked from commit 3c57c7357422bdfda60f56901a7590b258915b6b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
ee432b6431
commit
8adfacca61
@ -122,12 +122,12 @@ namespace {
|
|||||||
struct DiRegKeyHandleTraits
|
struct DiRegKeyHandleTraits
|
||||||
{
|
{
|
||||||
using Type = HKEY;
|
using Type = HKEY;
|
||||||
static Type invalidValue()
|
static Type invalidValue() noexcept
|
||||||
{
|
{
|
||||||
// The setupapi.h functions return INVALID_HANDLE_VALUE when failing to open a registry key
|
// The setupapi.h functions return INVALID_HANDLE_VALUE when failing to open a registry key
|
||||||
return reinterpret_cast<HKEY>(INVALID_HANDLE_VALUE);
|
return reinterpret_cast<HKEY>(INVALID_HANDLE_VALUE);
|
||||||
}
|
}
|
||||||
static bool close(Type handle) { return RegCloseKey(handle) == ERROR_SUCCESS; }
|
static bool close(Type handle) noexcept { return RegCloseKey(handle) == ERROR_SUCCESS; }
|
||||||
};
|
};
|
||||||
|
|
||||||
using DiRegKeyHandle = QUniqueHandle<DiRegKeyHandleTraits>;
|
using DiRegKeyHandle = QUniqueHandle<DiRegKeyHandleTraits>;
|
||||||
@ -135,11 +135,11 @@ using DiRegKeyHandle = QUniqueHandle<DiRegKeyHandleTraits>;
|
|||||||
struct DevInfoHandleTraits
|
struct DevInfoHandleTraits
|
||||||
{
|
{
|
||||||
using Type = HDEVINFO;
|
using Type = HDEVINFO;
|
||||||
static Type invalidValue()
|
static Type invalidValue() noexcept
|
||||||
{
|
{
|
||||||
return reinterpret_cast<HDEVINFO>(INVALID_HANDLE_VALUE);
|
return reinterpret_cast<HDEVINFO>(INVALID_HANDLE_VALUE);
|
||||||
}
|
}
|
||||||
static bool close(Type handle) { return SetupDiDestroyDeviceInfoList(handle) == TRUE; }
|
static bool close(Type handle) noexcept { return SetupDiDestroyDeviceInfoList(handle) == TRUE; }
|
||||||
};
|
};
|
||||||
|
|
||||||
using DevInfoHandle = QUniqueHandle<DevInfoHandleTraits>;
|
using DevInfoHandle = QUniqueHandle<DevInfoHandleTraits>;
|
||||||
|
@ -76,7 +76,7 @@ struct TestTraits
|
|||||||
{
|
{
|
||||||
using Type = GlobalResource::handle;
|
using Type = GlobalResource::handle;
|
||||||
|
|
||||||
static bool close(Type handle)
|
static bool close(Type handle) noexcept
|
||||||
{
|
{
|
||||||
return GlobalResource::close(handle);
|
return GlobalResource::close(handle);
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ private slots:
|
|||||||
{
|
{
|
||||||
using Type = int;
|
using Type = int;
|
||||||
|
|
||||||
static bool close(Type)
|
static bool close(Type) noexcept
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user