summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2024-09-11 14:54:09 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2024-09-12 08:51:24 +0200
commit10e2318bdeccdc33f95ebdb2c7683b816dda67fb (patch)
tree679b72a0b0810d6c036c92b88824b02cb1476274
parent97ef3c837263099faf02d8ebafd6c77c94d2aaba (diff)
downloadredot-engine-10e2318bdeccdc33f95ebdb2c7683b816dda67fb.tar.gz
Object: Let debug lock handle callee destruction within call chain gracefully
Co-authored-by: lawnjelly <lawnjelly@gmail.com>
-rw-r--r--core/object/object.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp
index d6b7d7a7fe..f6dded4a7d 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -45,14 +45,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();
+ }
}
};