only free console if program launches in gui mode

This commit is contained in:
itsmattkc
2021-08-14 11:36:30 -07:00
parent 42dd029f9e
commit d1d23e5400
+11 -7
View File
@@ -104,9 +104,11 @@ int main(int argc, char *argv[])
true, true,
QCoreApplication::translate("main", "qm-file")); QCoreApplication::translate("main", "qm-file"));
#ifdef _WIN32
auto console_option = auto console_option =
parser.AddOption({QStringLiteral("c"), QStringLiteral("-console")}, 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 = auto project_argument =
parser.AddPositionalArgument(QStringLiteral("project"), parser.AddPositionalArgument(QStringLiteral("project"),
@@ -133,12 +135,6 @@ int main(int argc, char *argv[])
parser.Process(argc, argv); parser.Process(argc, argv);
if (!console_option->IsSet()) {
#ifdef _WIN32
FreeConsole();
#endif // _WIN32
}
if (help_option->IsSet()) { if (help_option->IsSet()) {
// Show help // Show help
parser.PrintHelp(argv[0]); parser.PrintHelp(argv[0]);
@@ -193,6 +189,14 @@ int main(int argc, char *argv[])
std::unique_ptr<QCoreApplication> a; std::unique_ptr<QCoreApplication> a;
if (startup_params.run_mode() == olive::Core::CoreParams::kRunNormal) { 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)); a.reset(new QApplication(argc, argv));
} else { } else {
a.reset(new QCoreApplication(argc, argv)); a.reset(new QCoreApplication(argc, argv));