diff options
| author | Neil <nyamatongwe@gmail.com> | 2020-06-06 13:41:58 +1000 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2020-06-06 13:41:58 +1000 |
| commit | 554d1cc7c885291618ec50b6045e27fc1cf87a28 (patch) | |
| tree | 85b548fe63cc42a1487ad8f8122d341bcdad9138 /win32/PlatWin.h | |
| parent | f1f8eeddbe3437c3e3f4f4580435996ea3cd0904 (diff) | |
| download | scintilla-mirror-554d1cc7c885291618ec50b6045e27fc1cf87a28.tar.gz | |
Backport: Add ReleaseUnknown to safely release IUnknown* and avoid warnings when done in
noexcept context.
Backport of changeset 8286:bddda9b7df4f.
Diffstat (limited to 'win32/PlatWin.h')
| -rw-r--r-- | win32/PlatWin.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/win32/PlatWin.h b/win32/PlatWin.h index 2555daac0..23c889d14 100644 --- a/win32/PlatWin.h +++ b/win32/PlatWin.h @@ -52,6 +52,23 @@ T DLLFunction(HMODULE hModule, LPCSTR lpProcName) noexcept { return fp; } +// Release an IUnknown* and set to nullptr. +// While IUnknown::Release must be noexcept, it isn't marked as such so produces +// warnings which are avoided by the catch. +template <class T> +void ReleaseUnknown(T *&ppUnknown) noexcept { + if (ppUnknown) { + try { + ppUnknown->Release(); + } + catch (...) { + // Never occurs + } + ppUnknown = nullptr; + } +} + + UINT DpiForWindow(WindowID wid) noexcept; int SystemMetricsForDpi(int nIndex, UINT dpi) noexcept; |
