Object: Let debug lock handle callee destruction within call chain gracefully

Co-authored-by: lawnjelly <lawnjelly@gmail.com>
(cherry picked from commit 10e2318bde)
This commit is contained in:
Pedro J. Estébanez 2024-09-11 14:54:09 +02:00 committed by Rémi Verschelde
parent d92f9017c6
commit 018f8be3d5
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 7 additions and 4 deletions

View File

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