From 0cef15c0f237fec831f74132aa7413bcab2381ea Mon Sep 17 00:00:00 2001 From: asokolow Date: Tue, 27 Jun 2017 09:00:14 +0200 Subject: [PATCH 1/2] According to MSDN PeekMessage returns false only when the message queue is empty. If there is another message after WM_QUIT, the part of the code responsible for proper closing of the application would never be triggered. This change handles WM_QUIT message properly. --- base/vulkanexamplebase.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 7061dfb0..636f46b3 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -216,7 +216,8 @@ void VulkanExampleBase::renderLoop() destHeight = height; #if defined(_WIN32) MSG msg; - while (TRUE) + bool quitMessageReceived = false; + while (!quitMessageReceived) { auto tStart = std::chrono::high_resolution_clock::now(); if (viewUpdated) @@ -229,11 +230,12 @@ void VulkanExampleBase::renderLoop() { TranslateMessage(&msg); DispatchMessage(&msg); - } - if (msg.message == WM_QUIT) - { - break; + if (msg.message == WM_QUIT) + { + quitMessageReceived = true; + break; + } } render(); From ed207ab0300b0a671819db560d9e22a9fb0e62b5 Mon Sep 17 00:00:00 2001 From: asokolow Date: Tue, 27 Jun 2017 09:03:26 +0200 Subject: [PATCH 2/2] whitespace fix --- base/vulkanexamplebase.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 636f46b3..5dcc5a55 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -216,7 +216,7 @@ void VulkanExampleBase::renderLoop() destHeight = height; #if defined(_WIN32) MSG msg; - bool quitMessageReceived = false; + bool quitMessageReceived = false; while (!quitMessageReceived) { auto tStart = std::chrono::high_resolution_clock::now(); @@ -231,11 +231,11 @@ void VulkanExampleBase::renderLoop() TranslateMessage(&msg); DispatchMessage(&msg); - if (msg.message == WM_QUIT) - { - quitMessageReceived = true; - break; - } + if (msg.message == WM_QUIT) + { + quitMessageReceived = true; + break; + } } render();