Skip to content

Commit

Permalink
Support Windows Commandline
Browse files Browse the repository at this point in the history
  • Loading branch information
strseb committed Apr 9, 2024
1 parent ec516b5 commit 508ce1b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
14 changes: 0 additions & 14 deletions src/commands/commandui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,20 +187,6 @@ int CommandUI::run(QStringList& tokens) {
EventListener eventListener;
#endif

#ifdef MZ_WINDOWS
# ifdef MZ_DEBUG
// Allocate a console to view log output in debug mode on windows
if (AllocConsole()) {
FILE* unusedFile;
freopen_s(&unusedFile, "CONOUT$", "w", stdout);
freopen_s(&unusedFile, "CONOUT$", "w", stderr);
std::cout.clear();
std::clog.clear();
std::cerr.clear();
}
# endif
#endif

#ifdef MZ_DEBUG
// This enables the qt-creator qml debugger on debug builds.:
// Go to QtCreator: Debug->Start Debugging-> Attach to QML port
Expand Down
20 changes: 20 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,33 @@

#include "commandlineparser.h"
#include "leakdetector.h"
#include "stdio.h"
#ifdef MZ_WINDOWS

# include <windows.h>

# include <iostream>

#endif

Q_DECL_EXPORT int main(int argc, char* argv[]) {
#ifdef MZ_DEBUG
LeakDetector leakDetector;
Q_UNUSED(leakDetector);
#endif

#ifdef MZ_WINDOWS
if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) {
FILE* unusedFile;
// Swap to the new out/err streams
freopen_s(&unusedFile, "CONOUT$", "w", stdout);
freopen_s(&unusedFile, "CONOUT$", "w", stderr);
std::cout.clear();
std::clog.clear();
std::cerr.clear();
}
#endif

CommandLineParser clp;
return clp.parse(argc, argv);
}

0 comments on commit 508ce1b

Please sign in to comment.