Skip to content

Commit

Permalink
Merge pull request #6721 from spycrab/qt_alloc_console
Browse files Browse the repository at this point in the history
Qt/Win32: Fix console output
  • Loading branch information
lioncash committed Apr 30, 2018
2 parents d8b56af + a2dbf97 commit 1ce75ce
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Source/Core/DolphinQt2/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#ifdef _WIN32
#include <Windows.h>
#include <cstdio>
#endif

#include <OptionParser.h>
#include <QAbstractEventDispatcher>
#include <QApplication>
Expand Down Expand Up @@ -67,6 +72,16 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no
// /SubSystem:Windows
int main(int argc, char* argv[])
{
#ifdef _WIN32
const bool console_attached = AttachConsole(ATTACH_PARENT_PROCESS) != FALSE;
HANDLE stdout_handle = ::GetStdHandle(STD_OUTPUT_HANDLE);
if (console_attached && stdout_handle)
{
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
#endif

#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
Expand All @@ -82,6 +97,10 @@ int main(int argc, char* argv[])
const optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv);
const std::vector<std::string> args = parser->args();

#ifdef _WIN32
FreeConsole();
#endif

UICommon::SetUserDirectory(static_cast<const char*>(options.get("user")));
UICommon::CreateDirectories();
UICommon::Init();
Expand Down

0 comments on commit 1ce75ce

Please sign in to comment.