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:
Thomas Wilshaw
2021-08-09 23:14:12 +01:00
parent b1b057a628
commit 42dd029f9e
2 changed files with 11 additions and 34 deletions
-3
View File
@@ -101,9 +101,6 @@ if (WIN32)
# Set Windows application icon
target_sources(olive-editor PRIVATE packaging/windows/resources.rc)
set_target_properties(olive-editor PROPERTIES
WIN32_EXECUTABLE TRUE
)
elseif(APPLE)
# Set Mac application icon
set(OLIVE_ICON packaging/macos/olive.icns)
+11 -31
View File
@@ -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;
}