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

Merge pull request #96856 from RandomShaper/selfdestruct_correctness

Object: Let debug lock handle callee destruction within call chain gracefully
This commit is contained in:
Rémi Verschelde
2024-09-16 13:35:06 +02:00
4 changed files with 140 additions and 4 deletions

View File

@@ -44,14 +44,17 @@
#ifdef DEBUG_ENABLED
struct _ObjectDebugLock {
Object *obj;
ObjectID obj_id;
_ObjectDebugLock(Object *p_obj) {
obj = p_obj;
obj->_lock_index.ref();
obj_id = p_obj->get_instance_id();
p_obj->_lock_index.ref();
}
~_ObjectDebugLock() {
obj->_lock_index.unref();
Object *obj_ptr = ObjectDB::get_instance(obj_id);
if (likely(obj_ptr)) {
obj_ptr->_lock_index.unref();
}
}
};