Revert back to a console application
Revert Olive back to a console application and then hide the console on startup. Also add an option to run a console if required. Windows only.
This commit is contained in:
+11
-31
@@ -52,31 +52,6 @@ extern "C" {
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
bool console = false;
|
||||
FILE *stream_stdout;
|
||||
FILE *stream_stderr;
|
||||
|
||||
AttachConsole(ATTACH_PARENT_PROCESS);
|
||||
DWORD procIDs[2];
|
||||
DWORD maxIds = 2;
|
||||
DWORD count = GetConsoleProcessList((LPDWORD)procIDs, maxIds);
|
||||
|
||||
if (count == 2) {
|
||||
/* this is a terminal */
|
||||
FreeConsole();
|
||||
|
||||
// Create own console
|
||||
if (AllocConsole()) {
|
||||
freopen_s(&stream_stdout, "CONOUT$", "w", stdout);
|
||||
freopen_s(&stream_stderr, "CONOUT$", "w", stderr);
|
||||
console = true;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
// Set up debug handler
|
||||
qInstallMessageHandler(olive::DebugHandler);
|
||||
|
||||
@@ -129,10 +104,15 @@ int main(int argc, char *argv[])
|
||||
true,
|
||||
QCoreApplication::translate("main", "qm-file"));
|
||||
|
||||
auto console_option =
|
||||
parser.AddOption({QStringLiteral("c"), QStringLiteral("-console")},
|
||||
QCoreApplication::translate("main", "Launch console (Windows only)"));
|
||||
|
||||
auto project_argument =
|
||||
parser.AddPositionalArgument(QStringLiteral("project"),
|
||||
QCoreApplication::translate("main", "Project to open on startup"));
|
||||
|
||||
|
||||
// Qt options re-implemented (add to this as necessary)
|
||||
//
|
||||
// Because we don't use QCommandLineParser, we must filter out Qt's arguments ourselves. Here,
|
||||
@@ -153,6 +133,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
parser.Process(argc, argv);
|
||||
|
||||
if (!console_option->IsSet()) {
|
||||
#ifdef _WIN32
|
||||
FreeConsole();
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
||||
if (help_option->IsSet()) {
|
||||
// Show help
|
||||
parser.PrintHelp(argv[0]);
|
||||
@@ -237,11 +223,5 @@ int main(int argc, char *argv[])
|
||||
// Clear core memory
|
||||
c.Stop();
|
||||
|
||||
#ifdef _WIN32
|
||||
if (console) {
|
||||
system("pause");
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user