[Toast] Uninitialize if possible
This commit is contained in:
parent
d3ca680e7a
commit
a3cb37f7e4
@ -12,6 +12,11 @@ namespace Components
|
||||
return Loader::Pregame;
|
||||
}
|
||||
|
||||
bool Loader::IsPostgame()
|
||||
{
|
||||
return Loader::Postgame;
|
||||
}
|
||||
|
||||
void Loader::Initialize()
|
||||
{
|
||||
Loader::Pregame = true;
|
||||
@ -93,7 +98,7 @@ namespace Components
|
||||
|
||||
void Loader::Uninitialize()
|
||||
{
|
||||
Loader::PreDestroy();
|
||||
Loader::PreDestroyNoPostGame();
|
||||
|
||||
std::reverse(Loader::Components.begin(), Loader::Components.end());
|
||||
for (auto component : Loader::Components)
|
||||
@ -119,14 +124,32 @@ namespace Components
|
||||
{
|
||||
Loader::Postgame = true;
|
||||
|
||||
std::reverse(Loader::Components.begin(), Loader::Components.end());
|
||||
for (auto component : Loader::Components)
|
||||
auto components = Loader::Components;
|
||||
|
||||
std::reverse(components.begin(), components.end());
|
||||
for (auto component : components)
|
||||
{
|
||||
component->preDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Loader::PreDestroyNoPostGame()
|
||||
{
|
||||
if (!Loader::Postgame)
|
||||
{
|
||||
auto components = Loader::Components;
|
||||
|
||||
std::reverse(components.begin(), components.end());
|
||||
for (auto component : components)
|
||||
{
|
||||
component->preDestroy();
|
||||
}
|
||||
|
||||
Loader::Postgame = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Loader::PerformUnitTests()
|
||||
{
|
||||
bool result = true;
|
||||
|
@ -25,11 +25,13 @@ namespace Components
|
||||
static void Initialize();
|
||||
static void Uninitialize();
|
||||
static void PreDestroy();
|
||||
static void PreDestroyNoPostGame();
|
||||
static bool PerformUnitTests();
|
||||
static bool PerformingUnitTests();
|
||||
static void Register(Component* component);
|
||||
|
||||
static bool IsPregame();
|
||||
static bool IsPostgame();
|
||||
|
||||
static Utils::Memory::Allocator* GetAlloctor();
|
||||
|
||||
|
@ -174,8 +174,15 @@ namespace Components
|
||||
{
|
||||
if (Dedicated::IsEnabled()) return;
|
||||
|
||||
// Destroying that on the main thread deadlocks, for whatever reason.
|
||||
// Destroying that on the main thread deadlocks.
|
||||
// I did not write the library, so whatever.
|
||||
// If we are not in the postgame state,
|
||||
// we are not allowed to spawn threads,
|
||||
// so just don't uninitialize the library.
|
||||
// That means we did not uninitialize the game
|
||||
// correctly anyways.
|
||||
if (Loader::IsPostgame())
|
||||
{
|
||||
std::thread([]()
|
||||
{
|
||||
delete WinToastLib::WinToast::instance();
|
||||
@ -183,4 +190,10 @@ namespace Components
|
||||
Toast::ToastHandler = nullptr;
|
||||
}).join();
|
||||
}
|
||||
else
|
||||
{
|
||||
delete Toast::ToastHandler;
|
||||
Toast::ToastHandler = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user