diff options
author | Ignacio Etcheverry <neikeq@users.noreply.github.com> | 2017-11-01 01:56:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-01 01:56:16 +0100 |
commit | 3c97a9543d7c7abdecb3804a780da7105f2b2886 (patch) | |
tree | d88b080fccf8d90bca23eca992a464502c67caac /modules/mono/mono_gd | |
parent | cb3ef3c7e678af78b7cf24dfb780617938a74d42 (diff) | |
parent | a018cbaee1130c34a84557a1a9fdf5186ee99fd1 (diff) |
Merge pull request #12549 from neikeq/seriously-do-they
Mono cleanup fixes
Diffstat (limited to 'modules/mono/mono_gd')
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 6 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono_utils.h | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 904a8ae2c7..c997b0f000 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -705,7 +705,7 @@ bool _GodotSharp::is_domain_loaded() { void _GodotSharp::queue_dispose(Object *p_object) { - if (Thread::get_main_id() == Thread::get_caller_id() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) { + if (GDMonoUtils::is_main_thread() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) { _dispose_object(p_object); } else { #ifndef NO_THREADS @@ -722,7 +722,7 @@ void _GodotSharp::queue_dispose(Object *p_object) { void _GodotSharp::queue_dispose(NodePath *p_node_path) { - if (Thread::get_main_id() == Thread::get_caller_id() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) { + if (GDMonoUtils::is_main_thread() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) { memdelete(p_node_path); } else { #ifndef NO_THREADS @@ -739,7 +739,7 @@ void _GodotSharp::queue_dispose(NodePath *p_node_path) { void _GodotSharp::queue_dispose(RID *p_rid) { - if (Thread::get_main_id() == Thread::get_caller_id() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) { + if (GDMonoUtils::is_main_thread() && !GDMono::get_singleton()->is_finalizing_scripts_domain()) { memdelete(p_rid); } else { #ifndef NO_THREADS diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index e3af57e78a..ebb5d28e4d 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -149,6 +149,10 @@ void attach_current_thread(); void detach_current_thread(); MonoThread *get_current_thread(); +_FORCE_INLINE_ bool is_main_thread() { + return mono_domain_get() != NULL && mono_thread_get_main() == mono_thread_current(); +} + GDMonoClass *get_object_class(MonoObject *p_object); GDMonoClass *type_get_proxy_class(const StringName &p_type); GDMonoClass *get_class_native_base(GDMonoClass *p_class); |