diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2019-05-16 12:06:28 +0300 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2019-05-17 10:52:33 +0000 |
commit | 6ea22a1a9ef9d9be25e09740aa72bb0a5dfebfc7 (patch) | |
tree | 44d2eb55df3bac214bf753eea7945241674e8dc4 /src | |
parent | 9653c8607f04ab2cd741070b05f71503d32014bc (diff) |
Fix installer hang on Windows with empty command prompt window appearing
Installer sometimes hangs on Windows with a command prompt window opening
and blocking any progress. Hitting enter in this command prompt window
causes progress to move forward. This blocks automated execution of tests
since it requires manual interaction.
parentConsole boolean was not initialized properly, fix logically broken
closing actions for console.
Task-number: QTIFW-1250
Change-Id: I062c0491c16c26e9435022d79f99240bf59e1a79
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/sdk/console.h | 3 | ||||
-rw-r--r-- | src/sdk/console_win.cpp | 13 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/sdk/console.h b/src/sdk/console.h index 0ab6e4743..378a37e60 100644 --- a/src/sdk/console.h +++ b/src/sdk/console.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -44,6 +44,7 @@ public: private: bool parentConsole; + bool newConsoleCreated; std::ofstream m_newCout; std::ofstream m_newCerr; diff --git a/src/sdk/console_win.cpp b/src/sdk/console_win.cpp index f3226bc60..978159612 100644 --- a/src/sdk/console_win.cpp +++ b/src/sdk/console_win.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -74,7 +74,9 @@ static bool isRedirected(HANDLE stdHandle) */ Console::Console() : m_oldCout(nullptr), - m_oldCerr(nullptr) + m_oldCerr(nullptr), + parentConsole(false), + newConsoleCreated(false) { bool isCoutRedirected = isRedirected(GetStdHandle(STD_OUTPUT_HANDLE)); bool isCerrRedirected = isRedirected(GetStdHandle(STD_ERROR_HANDLE)); @@ -83,6 +85,7 @@ Console::Console() : // try to use parent console. else launch & set up new console parentConsole = AttachConsole(ATTACH_PARENT_PROCESS); if (!parentConsole) { + newConsoleCreated = true; AllocConsole(); HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); if (handle != INVALID_HANDLE_VALUE) { @@ -119,11 +122,11 @@ Console::Console() : Console::~Console() { - if (!parentConsole) { - system("PAUSE"); - } else { + if (parentConsole) { // simulate enter key to switch to boot prompt PostMessage(GetConsoleWindow(), WM_KEYDOWN, 0x0D, 0); + } else if (newConsoleCreated) { + system("PAUSE"); } if (m_oldCerr) |