winrt: Add convenience macros for returning from HRESULT calls
Almost every native call in WinRT uses COM HRESULTS. Provide some convenience macros for returning after failure. Task-number: QTBUG-39407 Change-Id: Ia99b0acd771d53c52732f270e46dd6937538e131 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
This commit is contained in:
parent
1ae61e95e4
commit
6d95ce1649
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
@ -118,5 +118,20 @@ generate_inline_return_func2(_putenv_s, errno_t, const char *, const char *)
|
||||
generate_inline_return_func0(tzset, void)
|
||||
generate_inline_return_func0(_tzset, void)
|
||||
|
||||
// Convenience macros for handling HRESULT values
|
||||
#define RETURN_IF_FAILED(msg, ret) \
|
||||
if (FAILED(hr)) { \
|
||||
qErrnoWarning(hr, msg); \
|
||||
ret; \
|
||||
}
|
||||
|
||||
#define RETURN_HR_IF_FAILED(msg) RETURN_IF_FAILED(msg, return hr)
|
||||
#define RETURN_OK_IF_FAILED(msg) RETURN_IF_FAILED(msg, return S_OK)
|
||||
#define RETURN_FALSE_IF_FAILED(msg) RETURN_IF_FAILED(msg, return false)
|
||||
#define RETURN_VOID_IF_FAILED(msg) RETURN_IF_FAILED(msg, return)
|
||||
|
||||
#define Q_ASSERT_SUCCEEDED(hr) \
|
||||
Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr)));
|
||||
|
||||
#endif // Q_OS_WINRT
|
||||
#endif // QFUNCTIONS_WINRT_H
|
||||
|
Loading…
Reference in New Issue
Block a user