From b35dcc34b9ca86c325845e911f7744c3e724c61a Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Sun, 5 Jul 2020 18:59:48 +0800 Subject: [PATCH] Improve error handling. Signed-off-by: Yuhang Zhao <2546789017@qq.com> --- winnativeeventfilter.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/winnativeeventfilter.cpp b/winnativeeventfilter.cpp index 84c26cc..482ba2b 100644 --- a/winnativeeventfilter.cpp +++ b/winnativeeventfilter.cpp @@ -141,11 +141,22 @@ bool isWin10OrGreator(const int ver) #define WNEF_SYSTEM_LIB_END } #endif +#ifndef WNEF_RESOLVE_ERROR +#ifdef _DEBUG +#define WNEF_RESOLVE_ERROR(funcName, errMsg) Q_ASSERT_X(m_lp##funcName, __FUNCTION__, errMsg); +#else +#define WNEF_RESOLVE_ERROR(funcName, errMsg) \ + if (!m_lp##funcName) { \ + qCritical().noquote() << "Failed to resolve symbol" << funcName << ':' << errMsg; \ + } +#endif +#endif + #ifndef WNEF_RESOLVE_WINAPI #define WNEF_RESOLVE_WINAPI(funcName) \ if (!m_lp##funcName) { \ m_lp##funcName = reinterpret_cast<_WNEF_WINAPI_##funcName>(library.resolve(#funcName)); \ - Q_ASSERT_X(m_lp##funcName, __FUNCTION__, qUtf8Printable(library.errorString())); \ + WNEF_RESOLVE_ERROR(funcName, qUtf8Printable(library.errorString())) \ } #endif