From 23907e6f193636c4907d0ccdb9a886fff63ab275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Mon, 22 Feb 2021 11:06:33 +0100 Subject: [PATCH] Make glue generation shutdown more graceful --- main/main.cpp | 6 ++++-- main/main.h | 2 +- modules/mono/editor/bindings_generator.cpp | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 41f97b2e3be5..4120af951f44 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2561,8 +2561,10 @@ void Main::force_redraw() { * so that the engine closes cleanly without leaking memory or crashing. * The order matters as some of those steps are linked with each other. */ -void Main::cleanup() { - ERR_FAIL_COND(!_start_success); +void Main::cleanup(bool p_force) { + if (!p_force) { + ERR_FAIL_COND(!_start_success); + } EngineDebugger::deinitialize(); diff --git a/main/main.h b/main/main.h index 9e606c188d9b..f4fff6b97e2e 100644 --- a/main/main.h +++ b/main/main.h @@ -59,7 +59,7 @@ public: static bool is_iterating(); - static void cleanup(); + static void cleanup(bool p_force = false); }; // Test main override is for the testing behaviour. diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 167e9d75a1de..a569dfc20740 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -39,6 +39,7 @@ #include "core/os/file_access.h" #include "core/os/os.h" #include "core/string/ucaps.h" +#include "main/main.h" #include "../glue/cs_glue_version.gen.h" #include "../godotsharp_defs.h" @@ -3649,6 +3650,7 @@ void BindingsGenerator::handle_cmdline_args(const List &p_cmdline_args) if (!bindings_generator.initialized) { ERR_PRINT("Failed to initialize the bindings generator"); + Main::cleanup(true); ::exit(0); } @@ -3675,6 +3677,7 @@ void BindingsGenerator::handle_cmdline_args(const List &p_cmdline_args) } // Exit once done + Main::cleanup(true); ::exit(0); } }