[Exception] Don't deadlock trying to close the window

This commit is contained in:
momo5502 2017-04-27 11:14:44 +02:00
parent f7a337f04c
commit d6a674b883
2 changed files with 16 additions and 4 deletions

View File

@ -35,7 +35,7 @@ namespace Assets
{ {
buffer->align(Utils::Stream::ALIGN_4); buffer->align(Utils::Stream::ALIGN_4);
// not sure if this is neede but both brushside and brushedge need it and it can't hurt // not sure if this is needed but both brushside and brushedge need it and it can't hurt
for (int i = 0; i < asset->numCPlanes; ++i) for (int i = 0; i < asset->numCPlanes; ++i)
{ {
builder->storePointer(&asset->cPlanes[i]); builder->storePointer(&asset->cPlanes[i]);

View File

@ -25,6 +25,12 @@ namespace Components
{ {
FreeConsole(); FreeConsole();
if(IsWindow(Console::GetWindow()) != FALSE)
{
CloseWindow(Console::GetWindow());
DestroyWindow(Console::GetWindow());
}
if (IsWindow(Window::GetWindow()) != FALSE) if (IsWindow(Window::GetWindow()) != FALSE)
{ {
CloseWindow(Window::GetWindow()); CloseWindow(Window::GetWindow());
@ -34,11 +40,17 @@ namespace Components
// This makes sure we either destroy the windows or wait till they are destroyed // This makes sure we either destroy the windows or wait till they are destroyed
MSG msg; MSG msg;
while (IsWindow(Window::GetWindow()) != FALSE && GetMessage(&msg, nullptr, NULL, NULL)) Utils::Time::Interval interval;
while (IsWindow(Window::GetWindow()) != FALSE && !interval.elapsed(2s))
{
if (PeekMessage(&msg, nullptr, NULL, NULL, PM_REMOVE))
{ {
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
std::this_thread::sleep_for(10ms);
}
} }
// This only suspends the main game threads, which is enough for us // This only suspends the main game threads, which is enough for us