From 602ca4f897121d79efb320201a52c2b194de0fa5 Mon Sep 17 00:00:00 2001 From: Tony Barbour Date: Mon, 12 Sep 2016 14:02:43 -0600 Subject: demos: Fix issue of making Vulkan calls from callback Change-Id: I6fcb41cbcd13e8ce5ace6f857d7dd54bad48aa55 --- demos/cube.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/demos/cube.c b/demos/cube.c index 6017444f..161771ee 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -66,6 +66,7 @@ #endif #ifdef _WIN32 +bool in_callback = false; #define ERR_EXIT(err_msg, err_class) \ do { \ if (!demo->suppress_popups) \ @@ -434,9 +435,11 @@ dbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, } #ifdef _WIN32 + in_callback = true; struct demo *demo = (struct demo*) pUserData; if (!demo->suppress_popups) MessageBox(NULL, message, "Alert", MB_OK); + in_callback = false; #else printf("%s\n", message); fflush(stdout); @@ -1993,7 +1996,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { PostQuitMessage(validation_error); break; case WM_PAINT: - demo_run(&demo); + // The validation callback calls MessageBox which can generate paint + // events - don't make more Vulkan calls if we got here from the + // callback + if (!in_callback) { + demo_run(&demo); + } break; case WM_GETMINMAXINFO: // set window's minimum size ((MINMAXINFO*)lParam)->ptMinTrackSize = demo.minsize; -- cgit v1.2.3