Resolved issue #778. Calling Valentina with "-h" option opens information

dialog instead of writing to console.
(grafted from 4fb29d9b4e5441c43704005e4776f87d548673e7)

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-12-10 13:17:04 +02:00
parent ef3c60b459
commit 0a66db7184
5 changed files with 31 additions and 0 deletions

View File

@ -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.

View File

@ -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

View File

@ -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>("VPieceNode");

View File

@ -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
{

View File

@ -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;