Add error handling for all possible failing of winrt::check_result (#8278)

This commit is contained in:
Mykhailo Pylyp 2020-12-01 12:03:24 +02:00 committed by GitHub
parent c6078e3136
commit d9ca68e6ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 4 deletions

View File

@ -233,7 +233,16 @@ void OverlayWindow::enable()
winkey_popup->apply_overlay_opacity(((float)overlayOpacity.value) / 100.0f); winkey_popup->apply_overlay_opacity(((float)overlayOpacity.value) / 100.0f);
winkey_popup->set_theme(theme.value); winkey_popup->set_theme(theme.value);
target_state = std::make_unique<TargetState>(pressTime.value); target_state = std::make_unique<TargetState>(pressTime.value);
winkey_popup->initialize(); try
{
winkey_popup->initialize();
}
catch (...)
{
Logger::critical("Winkey popup failed to initialize");
return;
}
#if defined(DISABLE_LOWLEVEL_HOOKS_WHEN_DEBUGGED) #if defined(DISABLE_LOWLEVEL_HOOKS_WHEN_DEBUGGED)
const bool hook_disabled = IsDebuggerPresent(); const bool hook_disabled = IsDebuggerPresent();
#else #else

View File

@ -3,6 +3,7 @@
#include "common/start_visible.h" #include "common/start_visible.h"
#include "keyboard_state.h" #include "keyboard_state.h"
#include "common/shared_constants.h" #include "common/shared_constants.h"
#include <common\logger\logger.h>
TargetState::TargetState(int ms_delay) : TargetState::TargetState(int ms_delay) :
// TODO: All this processing should be done w/o a separate thread etc. in pre_wnd_proc of winkey_popup to avoid // TODO: All this processing should be done w/o a separate thread etc. in pre_wnd_proc of winkey_popup to avoid
@ -143,13 +144,36 @@ void TargetState::thread_proc()
handle_hidden(); handle_hidden();
break; break;
case Timeout: case Timeout:
handle_timeout(); try
{
handle_timeout();
}
catch (...)
{
Logger::critical("Timeout, handle_timeout failed.");
}
break; break;
case Shown: case Shown:
handle_shown(false); try
{
handle_shown(false);
}
catch (...)
{
Logger::critical("Shown, handle_shown failed.");
}
break; break;
case ForceShown: case ForceShown:
handle_shown(true); try
{
handle_shown(true);
}
catch (...)
{
Logger::critical("ForceShown, handle_shown failed.");
}
break; break;
case Exiting: case Exiting:
default: default: