diff --git a/ChangeLog.txt b/ChangeLog.txt index 645493bce..5ea552860 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -73,6 +73,7 @@ - Fix issue. Curves look too wavy. - [#773] Tool Point intersection curve and axis cannot find desired intersection point. - [#776] Valentina cannot recognize translated functions. +- [#778] Calling Valentina with "-h" option opens information dialog instead of writing to console. # Version 0.5.0 May 9, 2017 - [#581] User can now filter input lists by keyword in function wizard. diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index 1b5899552..03f8781c6 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -43,6 +43,10 @@ int main(int argc, char *argv[]) QT_REQUIRE_VERSION(argc, argv, "5.2.0") +#if defined(Q_OS_WIN) + VAbstractApplication::WinAttachConsole(); +#endif + #ifndef Q_OS_MAC // supports natively InitHighDpiScaling(argc, argv); #endif //Q_OS_MAC diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index db60e26dc..d9201f3b6 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -48,6 +48,10 @@ int main(int argc, char *argv[]) QT_REQUIRE_VERSION(argc, argv, "5.2.0") +#if defined(Q_OS_WIN) + VAbstractApplication::WinAttachConsole(); +#endif + // Need to internally move a node inside a piece main path qRegisterMetaTypeStreamOperators("VPieceNode"); diff --git a/src/libs/vmisc/vabstractapplication.cpp b/src/libs/vmisc/vabstractapplication.cpp index d621a0794..8ca124e7d 100644 --- a/src/libs/vmisc/vabstractapplication.cpp +++ b/src/libs/vmisc/vabstractapplication.cpp @@ -234,6 +234,24 @@ QUndoStack *VAbstractApplication::getUndoStack() const return undoStack; } +//--------------------------------------------------------------------------------------------------------------------- +#if defined(Q_OS_WIN) +void VAbstractApplication::WinAttachConsole() +{ + /* Windows does not really support dual mode applications. + * To see console output we need to attach console. + * For case of using pipeline we check std output handler. + * Original idea: https://stackoverflow.com/a/41701133/3045403 + */ + auto stdout_type = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)); + if (stdout_type == FILE_TYPE_UNKNOWN && AttachConsole(ATTACH_PARENT_PROCESS)) + { + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + } +} +#endif + //--------------------------------------------------------------------------------------------------------------------- Unit VAbstractApplication::patternUnit() const { diff --git a/src/libs/vmisc/vabstractapplication.h b/src/libs/vmisc/vabstractapplication.h index b249afdf6..226ae258d 100644 --- a/src/libs/vmisc/vabstractapplication.h +++ b/src/libs/vmisc/vabstractapplication.h @@ -111,6 +111,10 @@ public: QString GetPPath() const; void SetPPath(const QString &value); +#if defined(Q_OS_WIN) + static void WinAttachConsole(); +#endif + protected: QUndoStack *undoStack;