aboutsummaryrefslogtreecommitdiff
path: root/launcher/Application.cpp
diff options
context:
space:
mode:
authorseth <getchoo@tuta.io>2023-08-06 15:37:44 -0400
committerGitHub <noreply@github.com>2023-08-06 15:37:44 -0400
commitefaf4024ab22a53a3ef05f0a41b746b7561e087c (patch)
tree0c77a8ee0df72980b6d3ee0911695a1a968e133d /launcher/Application.cpp
parent5b8c997180ac1d7eaab8d862a90846d2c0207642 (diff)
parentbae59a8c076cb3815a04fd79ee24a6a5137ab2da (diff)
downloadPrismLauncher-efaf4024ab22a53a3ef05f0a41b746b7561e087c.tar.gz
PrismLauncher-efaf4024ab22a53a3ef05f0a41b746b7561e087c.tar.bz2
PrismLauncher-efaf4024ab22a53a3ef05f0a41b746b7561e087c.zip
Merge pull request #1464 from Ryex/fix/windows-console-attach
[Windows] Fix attaching logs to console
Diffstat (limited to 'launcher/Application.cpp')
-rw-r--r--launcher/Application.cpp35
1 files changed, 7 insertions, 28 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index 7bfcce5f..e89b7659 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -135,13 +135,8 @@
#include "updater/MacSparkleUpdater.h"
#endif
-
#if defined Q_OS_WIN32
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-#include <stdio.h>
+#include "WindowsConsole.h"
#endif
#define STRINGIFY(x) #x
@@ -168,31 +163,15 @@ void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QSt
fflush(stderr);
}
-}
+} // namespace
-Application::Application(int &argc, char **argv) : QApplication(argc, argv)
+
+
+Application::Application(int& argc, char** argv) : QApplication(argc, argv)
{
#if defined Q_OS_WIN32
- // attach the parent console
- if(AttachConsole(ATTACH_PARENT_PROCESS))
- {
- // if attach succeeds, reopen and sync all the i/o
- if(freopen("CON", "w", stdout))
- {
- std::cout.sync_with_stdio();
- }
- if(freopen("CON", "w", stderr))
- {
- std::cerr.sync_with_stdio();
- }
- if(freopen("CON", "r", stdin))
- {
- std::cin.sync_with_stdio();
- }
- auto out = GetStdHandle (STD_OUTPUT_HANDLE);
- DWORD written;
- const char * endline = "\n";
- WriteConsole(out, endline, strlen(endline), &written, NULL);
+ // attach the parent console if stdout not already captured
+ if (AttachWindowsConsole()) {
consoleAttached = true;
}
#endif