You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Complain if casting a freed object in a debug session
The idea is to give the user a chance to realize a mistake that will cause a crash in a release build (or with no debugger attached).
This commit is contained in:
@@ -803,6 +803,25 @@ bool Variant::is_one() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
ObjectID Variant::get_object_instance_id() const {
|
||||
if (type != OBJECT) {
|
||||
return 0;
|
||||
}
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (is_ref()) {
|
||||
return !_get_obj().ref.is_null() ? _REF_OBJ_PTR(*this)->get_instance_id() : 0;
|
||||
} else {
|
||||
return _get_obj().rc->instance_id;
|
||||
}
|
||||
#else
|
||||
if (is_ref() && _get_obj().ref.is_null()) {
|
||||
return 0;
|
||||
} else {
|
||||
return _get_obj().obj->get_instance_id();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Variant::reference(const Variant &p_variant) {
|
||||
switch (type) {
|
||||
case NIL:
|
||||
|
||||
Reference in New Issue
Block a user