[win] Move CoInit class to laf-base

This commit is contained in:
David Capello 2024-11-14 13:03:54 -03:00
parent 84f3101681
commit 3b7f78f41c
2 changed files with 6 additions and 18 deletions

2
laf

@ -1 +1 @@
Subproject commit 7af127f4785ac0fb0e50fa32e68e572719477f2a
Subproject commit e2055386fb2c786594afbc1c978471498e9cdf8f

View File

@ -23,6 +23,10 @@
#include "os/system.h"
#include "ver/info.h"
#if LAF_WINDOWS
#include "base/win/coinit.h"
#endif
#if ENABLE_SENTRY
#include "app/sentry_wrapper.h"
#if LAF_WINDOWS
@ -55,22 +59,6 @@ namespace {
#endif
};
#if LAF_WINDOWS
// Successful calls to CoInitialize() (S_OK or S_FALSE) must match
// the calls to CoUninitialize().
// From: https://docs.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-couninitialize#remarks
struct CoInit {
HRESULT hr;
CoInit() {
hr = CoInitialize(nullptr);
}
~CoInit() {
if (hr == S_OK || hr == S_FALSE)
CoUninitialize();
}
};
#endif // LAF_WINDOWS
#if USE_SENTRY_BREADCRUMB_FOR_WINTAB
// Delegate to write Wintab information as a Sentry breadcrumb (to
// know if there is a specific Wintab driver giving problems)
@ -110,7 +98,7 @@ int app_main(int argc, char* argv[])
std::srand(static_cast<unsigned int>(std::time(nullptr)));
#if LAF_WINDOWS
CoInit com; // To create COM objects
base::CoInit com; // To create COM objects
#endif
// Main thread name