summaryrefslogtreecommitdiffstats
path: root/src/sdk
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-07-11 09:32:39 +0200
committerKai Koehne <kai.koehne@digia.com>2014-07-11 14:18:31 +0200
commite6390254c683d210ca837eb137b027146fdd9d3a (patch)
tree9985e45ba4c8583b788cf15f3a4efc04a2d5fc7f /src/sdk
parent6e7ff8a60ba2bf3dcab1646f0046fc4ef7066cb3 (diff)
Windows: Write verbose output into parent console
Don't open a new console window for verbose output if we got launched from a console already, but attach to the parent console. This allows users to e.g. pipe the verbose output to a file. Change-Id: Ie602bdd18ef48b576e4b90806541709394882735 Reviewed-by: Niels Weber <niels.weber@digia.com> Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src/sdk')
-rw-r--r--src/sdk/console.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/sdk/console.h b/src/sdk/console.h
index 7eb4aa3f4..8e627574d 100644
--- a/src/sdk/console.h
+++ b/src/sdk/console.h
@@ -68,6 +68,10 @@ class Console
public:
Console()
{
+ parentConsole = AttachConsole(ATTACH_PARENT_PROCESS);
+ if (parentConsole)
+ return;
+
AllocConsole();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (handle != INVALID_HANDLE_VALUE) {
@@ -102,16 +106,20 @@ public:
~Console()
{
- system("PAUSE");
+ if (!parentConsole) {
+ system("PAUSE");
- std::cin.rdbuf(m_oldCin);
- std::cerr.rdbuf(m_oldCerr);
- std::cout.rdbuf(m_oldCout);
+ std::cin.rdbuf(m_oldCin);
+ std::cerr.rdbuf(m_oldCerr);
+ std::cout.rdbuf(m_oldCout);
+ }
FreeConsole();
}
private:
+ bool parentConsole;
+
std::ifstream m_newCin;
std::ofstream m_newCout;
std::ofstream m_newCerr;