[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);
// 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)
{
builder->storePointer(&asset->cPlanes[i]);

View File

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