From bec2fc19fd18768b16925597871c77a61e716abd Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Tue, 14 Jun 2016 22:46:08 +0200 Subject: Windows/QProcess::startDetached(): Don't always create console Make QProcess::startDetached() behave exactly like QProcess::start() when it comes to the behavior of whether to create a new console window or not. Before this patch, QProcess::startDetached() created a new console window (CREATE_NEW_CONSOLE flag of CreateProcess()) unconditionally. Instead, use the same rules for deducing whether to show an console window or not as QProcess::start(). [ChangeLog][QtCore][Platform Specific Changes] QProcess::startDetached() changed behavior on Windows: it no longer creates a new console window unconditionally, instead it passes the same creation flags to CreateProcess as QProcess::start(). Task-number: QTBUG-53833 Change-Id: I0e3d4b161fb5cb94cfbbd21fb4edb8417ab543fd Reviewed-by: David Faure Reviewed-by: Oswald Buddenhagen Reviewed-by: Joerg Bornemann --- src/corelib/io/qprocess_win.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 96b39efe3a..8579db1694 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -867,13 +867,15 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a bool success = false; PROCESS_INFORMATION pinfo; + DWORD dwCreationFlags = (GetConsoleWindow() ? 0 : CREATE_NO_WINDOW); + dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT; STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0, (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; success = CreateProcess(0, (wchar_t*)args.utf16(), - 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0, + 0, 0, FALSE, dwCreationFlags, 0, workingDir.isEmpty() ? 0 : (wchar_t*)workingDir.utf16(), &startupInfo, &pinfo); -- cgit v1.2.3