Merge pull request #6721 from spycrab/qt_alloc_console
Qt/Win32: Fix console output
This commit is contained in:
commit
1ce75ce217
|
@ -2,6 +2,11 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <cstdio>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <OptionParser.h>
|
#include <OptionParser.h>
|
||||||
#include <QAbstractEventDispatcher>
|
#include <QAbstractEventDispatcher>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -67,6 +72,16 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no
|
||||||
// /SubSystem:Windows
|
// /SubSystem:Windows
|
||||||
int main(int argc, char* argv[])
|
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)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,6 +97,10 @@ int main(int argc, char* argv[])
|
||||||
const optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv);
|
const optparse::Values& options = CommandLineParse::ParseArguments(parser.get(), argc, argv);
|
||||||
const std::vector<std::string> args = parser->args();
|
const std::vector<std::string> args = parser->args();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
FreeConsole();
|
||||||
|
#endif
|
||||||
|
|
||||||
UICommon::SetUserDirectory(static_cast<const char*>(options.get("user")));
|
UICommon::SetUserDirectory(static_cast<const char*>(options.get("user")));
|
||||||
UICommon::CreateDirectories();
|
UICommon::CreateDirectories();
|
||||||
UICommon::Init();
|
UICommon::Init();
|
||||||
|
|
Loading…
Reference in New Issue