diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index f2e95c1aa..83f58967a 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -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) diff --git a/app/main.cpp b/app/main.cpp index b3287d85f..a0a583b16 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -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; }