Skip to content

Commit ddb7257

Browse files
j388923rlalitb
andauthored
Catch exception when accessing Application::Current in WindowsRTPlatformEventHandler deconstructor like in the constructor as both have the same risk of throwing the exception (#1072)
Co-authored-by: Lalit Kumar Bhasin <[email protected]>
1 parent b18988f commit ddb7257

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

lib/shared/WindowsRTPlatformEventHandler.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,26 @@ namespace Microsoft {
6363

6464
PlatformEventHandler::~PlatformEventHandler()
6565
{
66-
if (this->m_suspendToken.Value != 0)
66+
try
6767
{
68-
Application::Current->Suspending -= this->m_suspendToken;
69-
}
68+
if (this->m_suspendToken.Value != 0)
69+
{
70+
Application::Current->Suspending -= this->m_suspendToken;
71+
}
7072

71-
if (this->m_resumeToken.Value != 0)
72-
{
73-
Application::Current->Resuming -= this->m_resumeToken;
74-
}
73+
if (this->m_resumeToken.Value != 0)
74+
{
75+
Application::Current->Resuming -= this->m_resumeToken;
76+
}
7577

76-
if (this->m_unhandledExceptionToken.Value != 0)
78+
if (this->m_unhandledExceptionToken.Value != 0)
79+
{
80+
Application::Current->UnhandledException -= this->m_unhandledExceptionToken;
81+
}
82+
}
83+
catch (Exception^ e)
7784
{
78-
Application::Current->UnhandledException -= this->m_unhandledExceptionToken;
85+
// Access to Application::Current can generate COM exceptions.
7986
}
8087
}
8188

0 commit comments

Comments
 (0)