mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 14:11:15 +00:00
Merge pull request #51796 from RandomShaper/dangling_obj_release_3.x
[3.x] Promote object validity checks to release builds
This commit is contained in:
commit
22aab6be1c
13 changed files with 71 additions and 152 deletions
|
|
@ -961,7 +961,6 @@ void Object::cancel_delete() {
|
|||
_predelete_ok = true;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
ObjectRC *Object::_use_rc() {
|
||||
// The RC object is lazily created the first time it's requested;
|
||||
// that way, there's no need to allocate and release it at all if this Object
|
||||
|
|
@ -989,7 +988,6 @@ ObjectRC *Object::_use_rc() {
|
|||
rc = _rc.load(std::memory_order_acquire);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void Object::set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_instance) {
|
||||
//this function is not meant to be used in any of these ways
|
||||
|
|
@ -1927,9 +1925,7 @@ Object::Object() {
|
|||
_emitting = false;
|
||||
memset(_script_instance_bindings, 0, sizeof(void *) * MAX_SCRIPT_INSTANCE_BINDINGS);
|
||||
script_instance = nullptr;
|
||||
#ifdef DEBUG_ENABLED
|
||||
_rc.store(nullptr, std::memory_order_release);
|
||||
#endif
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
||||
_edited = false;
|
||||
|
|
@ -1942,14 +1938,12 @@ Object::Object() {
|
|||
}
|
||||
|
||||
Object::~Object() {
|
||||
#ifdef DEBUG_ENABLED
|
||||
ObjectRC *rc = _rc.load(std::memory_order_acquire);
|
||||
if (rc) {
|
||||
if (rc->invalidate()) {
|
||||
memdelete(rc);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (script_instance) {
|
||||
memdelete(script_instance);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue