1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Added mono_unhandled_exception call to unhandled_exception hook

(cherry picked from commit 6061ff7ba1)
This commit is contained in:
Ilya Kuznetsov
2021-02-18 16:18:33 +01:00
committed by Rémi Verschelde
parent 33628c482f
commit cacf96962d
5 changed files with 55 additions and 2 deletions

View File

@@ -41,7 +41,6 @@
#include <mono/metadata/exception.h>
namespace GDMonoInternals {
void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
// This method should not fail
@@ -112,9 +111,11 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
void unhandled_exception(MonoException *p_exc) {
mono_print_unhandled_exception((MonoObject *)p_exc);
gd_unhandled_exception_event(p_exc);
if (GDMono::get_singleton()->get_unhandled_exception_policy() == GDMono::POLICY_TERMINATE_APP) {
// Too bad 'mono_invoke_unhandled_exception_hook' is not exposed to embedders
mono_unhandled_exception((MonoObject *)p_exc);
GDMono::unhandled_exception_hook((MonoObject *)p_exc, NULL);
GD_UNREACHABLE();
} else {
@@ -126,4 +127,13 @@ void unhandled_exception(MonoException *p_exc) {
}
}
void gd_unhandled_exception_event(MonoException *p_exc) {
MonoImage *mono_image = GDMono::get_singleton()->get_core_api_assembly()->get_image();
MonoClass *gd_klass = mono_class_from_name(mono_image, "Godot", "GD");
MonoMethod *unhandled_exception_method = mono_class_get_method_from_name(gd_klass, "OnUnhandledException", -1);
void *args[1];
args[0] = p_exc;
mono_runtime_invoke(unhandled_exception_method, nullptr, (void **)args, nullptr);
}
} // namespace GDMonoInternals