summaryrefslogtreecommitdiff
path: root/modules/mono/mono_gd
diff options
context:
space:
mode:
authorIgnacio Etcheverry <ignalfonsore@gmail.com>2018-01-26 01:10:21 +0100
committerIgnacio Etcheverry <ignalfonsore@gmail.com>2018-01-26 01:10:25 +0100
commit562ec3f5e6260592e14db3d7d388eb5585c99381 (patch)
tree06c08983cf69d77b5ff56cb10fad7ea2cc723b8a /modules/mono/mono_gd
parent76ec7280036930a7701d0a92a817ca3a79fcd936 (diff)
Mono: Don't defer call to dispose queue objects when finalizing domain
It's going to be called anyway after `mono_domain_finalize`. This also prevents crashes, since the MessageQueue singleton could already be freed at this point (see: #15702).
Diffstat (limited to 'modules/mono/mono_gd')
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index 6c07c90f79..f5febd415b 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -696,11 +696,13 @@ bool _GodotSharp::is_domain_loaded() {
return GDMono::get_singleton()->get_scripts_domain() != NULL;
}
-#define ENQUEUE_FOR_DISPOSAL(m_queue, m_inst) \
- m_queue.push_back(m_inst); \
- if (queue_empty) { \
- queue_empty = false; \
- call_deferred("_dispose_callback"); \
+#define ENQUEUE_FOR_DISPOSAL(m_queue, m_inst) \
+ m_queue.push_back(m_inst); \
+ if (queue_empty) { \
+ queue_empty = false; \
+ if (!is_finalizing_domain()) { /* call_deferred may not be safe here */ \
+ call_deferred("_dispose_callback"); \
+ } \
}
void _GodotSharp::queue_dispose(MonoObject *p_mono_object, Object *p_object) {