Skip to content

Commit 8975241

Browse files
committed
Call app shutdown only if OnExit succeeds
1 parent b174546 commit 8975241

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

src/dll/States/ShutdownState.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,21 @@ bool States::ShutdownState::OnExit(RED4ext::CShutdownState* aThis, RED4ext::CGam
5454
stateSystem->OnExit(RED4ext::EGameStateType::Shutdown, aApp);
5555
const bool result = CShutdownState.OnExit(aThis, aApp);
5656

57-
try
57+
if (result)
5858
{
59-
app->Shutdown();
60-
}
61-
catch (const std::exception& e)
62-
{
63-
SHOW_MESSAGE_BOX_AND_EXIT_FILE_LINE("An exception occurred while RED4ext was shutting down.\n\n{}",
64-
Utils::Widen(e.what()));
65-
}
66-
catch (...)
67-
{
68-
SHOW_MESSAGE_BOX_AND_EXIT_FILE_LINE("An unknown exception occurred while RED4ext was shutting down.");
59+
try
60+
{
61+
app->Shutdown();
62+
}
63+
catch (const std::exception& e)
64+
{
65+
SHOW_MESSAGE_BOX_AND_EXIT_FILE_LINE("An exception occurred while RED4ext was shutting down.\n\n{}",
66+
Utils::Widen(e.what()));
67+
}
68+
catch (...)
69+
{
70+
SHOW_MESSAGE_BOX_AND_EXIT_FILE_LINE("An unknown exception occurred while RED4ext was shutting down.");
71+
}
6972
}
7073

7174
return result;

0 commit comments

Comments
 (0)