diff options
author | Yuhang Zhao <2546789017@qq.com> | 2022-10-24 14:28:03 +0800 |
---|---|---|
committer | Yuhang Zhao <2546789017@qq.com> | 2022-12-02 18:35:52 +0800 |
commit | 67715b0095ba32b58d738a244f1568fcc029e687 (patch) | |
tree | 1b49d101f11496da00639ccd817e054f29951c0a /src/corelib/kernel/qcoreapplication_p.h | |
parent | b977ae371a753a82e1d0bb32c5b62099da663721 (diff) |
Win: redirect console output to the parent process if needed
We need to redirect the console output to the parent process
for GUI applications on Windows, otherwise we won't get any
output if we start the application from the console, because
the SUBSYSTEM of GUI applications is not CONSOLE by default.
But we don't want to change the default behavior of Qt, so
we control this feature through an environment variable
"QT_WIN_DEBUG_CONSOLE". It accepts two string values:
(1) "new": the application will try to create a separate
console window and redirect everything (cin/cout/clog/cerr)
to it. If you are running the application in an IDE, you
won't be able to get anything from the IDE's console anymore.
(2) "attach": the application will try to attach to the parent
process's console, if there is one. When we attached to it
successfully, we'll redirect everything to it.
Change-Id: I3ef98f6c0603f64fcc4e8e974411c5ed83c5d36f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication_p.h')
-rw-r--r-- | src/corelib/kernel/qcoreapplication_p.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 94c4b0f1e9..56d726cff5 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -73,6 +73,7 @@ public: static QString infoDictionaryStringProperty(const QString &propertyName); #endif + void initConsole(); static void initLocale(); static bool checkInstance(const char *method); @@ -125,6 +126,7 @@ public: #if defined(Q_OS_WIN) int origArgc; char **origArgv; // store unmodified arguments for QCoreApplication::arguments() + bool consoleAllocated = false; #endif void appendApplicationPathToLibraryPaths(void); |