From d1d23e540069eacca0f59fb086f9a2b507496758 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Sat, 14 Aug 2021 11:36:30 -0700 Subject: [PATCH] only free console if program launches in gui mode --- app/main.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index a0a583b16..f177be0de 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -104,9 +104,11 @@ int main(int argc, char *argv[]) true, QCoreApplication::translate("main", "qm-file")); +#ifdef _WIN32 auto console_option = parser.AddOption({QStringLiteral("c"), QStringLiteral("-console")}, - QCoreApplication::translate("main", "Launch console (Windows only)")); + QCoreApplication::translate("main", "Launch with debug console")); +#endif // _WIN32 auto project_argument = parser.AddPositionalArgument(QStringLiteral("project"), @@ -133,12 +135,6 @@ 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]); @@ -193,6 +189,14 @@ int main(int argc, char *argv[]) std::unique_ptr a; if (startup_params.run_mode() == olive::Core::CoreParams::kRunNormal) { +#ifdef _WIN32 + // Since Olive is linked with the console subsystem (for better POSIX compatibility), a console + // is created by default. If the user didn't request one, we free it here. + if (!console_option->IsSet()) { + FreeConsole(); + } +#endif // _WIN32 + a.reset(new QApplication(argc, argv)); } else { a.reset(new QCoreApplication(argc, argv));