From bcb0a4fe3cd339b9de03ab267ea785c0c08f03a6 Mon Sep 17 00:00:00 2001 From: Dustin Graves Date: Mon, 15 Feb 2016 15:54:52 -0700 Subject: demos: Adjust vulkaninfo failure cases For Windows, after vulkaninfo allocates a console, it tries to resize the console and change the title text. Failure of either operation was treated as console icreation failure, which led to vulkaninfo printing to the console and then closing the console immediately. Now treating AllocConsole() failure as console creation failure and ignoring resize and title text change failures. With this change, resize failure will not stop the app from pausing after printing info to the console. --- demos/vulkaninfo.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/demos/vulkaninfo.c b/demos/vulkaninfo.c index 8f768bf5..8549b3a5 100644 --- a/demos/vulkaninfo.c +++ b/demos/vulkaninfo.c @@ -1213,7 +1213,8 @@ bool SetStdOutToNewConsole() { return false; // allocate a console for this app - AllocConsole(); + if (!AllocConsole()) + return false; // redirect unbuffered STDOUT to the console HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); @@ -1224,23 +1225,22 @@ bool SetStdOutToNewConsole() { // make the console window bigger CONSOLE_SCREEN_BUFFER_INFO csbi; - SMALL_RECT r; COORD bufferSize; - if (!GetConsoleScreenBufferInfo(consoleHandle, &csbi)) - return false; - bufferSize.X = csbi.dwSize.X + 30; - bufferSize.Y = 20000; - if (!SetConsoleScreenBufferSize(consoleHandle, bufferSize)) - return false; + if (GetConsoleScreenBufferInfo(consoleHandle, &csbi)) + { + bufferSize.X = csbi.dwSize.X + 30; + bufferSize.Y = 20000; + SetConsoleScreenBufferSize(consoleHandle, bufferSize); + } + + SMALL_RECT r; r.Left = r.Top = 0; r.Right = csbi.dwSize.X - 1 + 30; r.Bottom = 50; - if (!SetConsoleWindowInfo(consoleHandle, true, &r)) - return false; + SetConsoleWindowInfo(consoleHandle, true, &r); // change the console window title - if (!SetConsoleTitle(TEXT(APP_SHORT_NAME))) - return false; + SetConsoleTitle(TEXT(APP_SHORT_NAME)); return true; } -- cgit v1.2.3