Make errors on RefCounted.free() more accurate

This commit is contained in:
Pedro J. Estébanez 2024-07-12 00:04:59 +02:00
parent ec02d406ca
commit 76bfe8e0fd
2 changed files with 3 additions and 3 deletions

View File

@ -763,7 +763,7 @@ Variant Object::callp(const StringName &p_method, const Variant **p_args, int p_
} }
if (is_ref_counted()) { if (is_ref_counted()) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD; r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
ERR_FAIL_V_MSG(Variant(), "Can't 'free' a reference."); ERR_FAIL_V_MSG(Variant(), "Can't free a RefCounted object.");
} }
if (_lock_index.get() > 1) { if (_lock_index.get() > 1) {

View File

@ -1794,7 +1794,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
} else if (methodstr == "free") { } else if (methodstr == "free") {
if (err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) { if (err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) {
if (base->is_ref_counted()) { if (base->is_ref_counted()) {
err_text = "Attempted to free a reference."; err_text = "Attempted to free a RefCounted object.";
OPCODE_BREAK; OPCODE_BREAK;
} else if (base->get_type() == Variant::OBJECT) { } else if (base->get_type() == Variant::OBJECT) {
err_text = "Attempted to free a locked object (calling or emitting)."; err_text = "Attempted to free a locked object (calling or emitting).";
@ -1885,7 +1885,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
} else if (methodstr == "free") { } else if (methodstr == "free") {
if (err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) { if (err.error == Callable::CallError::CALL_ERROR_INVALID_METHOD) {
if (base->is_ref_counted()) { if (base->is_ref_counted()) {
err_text = "Attempted to free a reference."; err_text = "Attempted to free a RefCounted object.";
OPCODE_BREAK; OPCODE_BREAK;
} else if (base->get_type() == Variant::OBJECT) { } else if (base->get_type() == Variant::OBJECT) {
err_text = "Attempted to free a locked object (calling or emitting)."; err_text = "Attempted to free a locked object (calling or emitting).";