You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
227
core/object.cpp
227
core/object.cpp
@@ -76,24 +76,29 @@ PropertyInfo::operator Dictionary() const {
|
||||
PropertyInfo PropertyInfo::from_dict(const Dictionary &p_dict) {
|
||||
PropertyInfo pi;
|
||||
|
||||
if (p_dict.has("type"))
|
||||
if (p_dict.has("type")) {
|
||||
pi.type = Variant::Type(int(p_dict["type"]));
|
||||
}
|
||||
|
||||
if (p_dict.has("name"))
|
||||
if (p_dict.has("name")) {
|
||||
pi.name = p_dict["name"];
|
||||
}
|
||||
|
||||
if (p_dict.has("class_name"))
|
||||
if (p_dict.has("class_name")) {
|
||||
pi.class_name = p_dict["class_name"];
|
||||
}
|
||||
|
||||
if (p_dict.has("hint"))
|
||||
if (p_dict.has("hint")) {
|
||||
pi.hint = PropertyHint(int(p_dict["hint"]));
|
||||
}
|
||||
|
||||
if (p_dict.has("hint_string"))
|
||||
|
||||
if (p_dict.has("hint_string")) {
|
||||
pi.hint_string = p_dict["hint_string"];
|
||||
}
|
||||
|
||||
if (p_dict.has("usage"))
|
||||
if (p_dict.has("usage")) {
|
||||
pi.usage = p_dict["usage"];
|
||||
}
|
||||
|
||||
return pi;
|
||||
}
|
||||
@@ -112,8 +117,9 @@ MethodInfo::operator Dictionary() const {
|
||||
d["name"] = name;
|
||||
d["args"] = convert_property_list(&arguments);
|
||||
Array da;
|
||||
for (int i = 0; i < default_arguments.size(); i++)
|
||||
for (int i = 0; i < default_arguments.size(); i++) {
|
||||
da.push_back(default_arguments[i]);
|
||||
}
|
||||
d["default_args"] = da;
|
||||
d["flags"] = flags;
|
||||
d["id"] = id;
|
||||
@@ -130,8 +136,9 @@ MethodInfo::MethodInfo() :
|
||||
MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
|
||||
MethodInfo mi;
|
||||
|
||||
if (p_dict.has("name"))
|
||||
if (p_dict.has("name")) {
|
||||
mi.name = p_dict["name"];
|
||||
}
|
||||
Array args;
|
||||
if (p_dict.has("args")) {
|
||||
args = p_dict["args"];
|
||||
@@ -153,8 +160,9 @@ MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
|
||||
mi.return_val = PropertyInfo::from_dict(p_dict["return"]);
|
||||
}
|
||||
|
||||
if (p_dict.has("flags"))
|
||||
if (p_dict.has("flags")) {
|
||||
mi.flags = p_dict["flags"];
|
||||
}
|
||||
|
||||
return mi;
|
||||
}
|
||||
@@ -345,26 +353,33 @@ bool Object::Connection::operator<(const Connection &p_conn) const {
|
||||
} else {
|
||||
return target < p_conn.target;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
return signal < p_conn.signal;
|
||||
}
|
||||
} else {
|
||||
return source < p_conn.source;
|
||||
}
|
||||
}
|
||||
Object::Connection::Connection(const Variant &p_variant) {
|
||||
Dictionary d = p_variant;
|
||||
if (d.has("source"))
|
||||
if (d.has("source")) {
|
||||
source = d["source"];
|
||||
if (d.has("signal"))
|
||||
}
|
||||
if (d.has("signal")) {
|
||||
signal = d["signal"];
|
||||
if (d.has("target"))
|
||||
}
|
||||
if (d.has("target")) {
|
||||
target = d["target"];
|
||||
if (d.has("method"))
|
||||
}
|
||||
if (d.has("method")) {
|
||||
method = d["method"];
|
||||
if (d.has("flags"))
|
||||
}
|
||||
if (d.has("flags")) {
|
||||
flags = d["flags"];
|
||||
if (d.has("binds"))
|
||||
}
|
||||
if (d.has("binds")) {
|
||||
binds = d["binds"];
|
||||
}
|
||||
}
|
||||
|
||||
bool Object::_predelete() {
|
||||
@@ -395,8 +410,9 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
|
||||
|
||||
if (script_instance) {
|
||||
if (script_instance->set(p_name, p_value)) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -414,23 +430,26 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
|
||||
|
||||
if (p_name == CoreStringNames::get_singleton()->_script) {
|
||||
set_script(p_value);
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return;
|
||||
|
||||
} else if (p_name == CoreStringNames::get_singleton()->_meta) {
|
||||
//set_meta(p_name,p_value);
|
||||
metadata = p_value.duplicate();
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//something inside the object... :|
|
||||
bool success = _setv(p_name, p_value);
|
||||
if (success) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -438,8 +457,9 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
|
||||
bool valid;
|
||||
setvar(p_name, p_value, &valid);
|
||||
if (valid) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -449,15 +469,17 @@ void Object::set(const StringName &p_name, const Variant &p_value, bool *r_valid
|
||||
bool valid;
|
||||
script_instance->property_set_fallback(p_name, p_value, &valid);
|
||||
if (valid) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
Variant Object::get(const StringName &p_name, bool *r_valid) const {
|
||||
@@ -465,8 +487,9 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
|
||||
|
||||
if (script_instance) {
|
||||
if (script_instance->get(p_name, ret)) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -474,30 +497,34 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
|
||||
//try built-in setgetter
|
||||
{
|
||||
if (ClassDB::get_property(const_cast<Object *>(this), p_name, ret)) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (p_name == CoreStringNames::get_singleton()->_script) {
|
||||
ret = get_script();
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return ret;
|
||||
|
||||
} else if (p_name == CoreStringNames::get_singleton()->_meta) {
|
||||
ret = metadata;
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return ret;
|
||||
|
||||
} else {
|
||||
//something inside the object... :|
|
||||
bool success = _getv(p_name, ret);
|
||||
if (success) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -506,8 +533,9 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
|
||||
bool valid;
|
||||
ret = getvar(p_name, &valid);
|
||||
if (valid) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -517,23 +545,26 @@ Variant Object::get(const StringName &p_name, bool *r_valid) const {
|
||||
bool valid;
|
||||
ret = script_instance->property_get_fallback(p_name, &valid);
|
||||
if (valid) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
return Variant();
|
||||
}
|
||||
}
|
||||
|
||||
void Object::set_indexed(const Vector<StringName> &p_names, const Variant &p_value, bool *r_valid) {
|
||||
if (p_names.empty()) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (p_names.size() == 1) {
|
||||
@@ -542,8 +573,9 @@ void Object::set_indexed(const Vector<StringName> &p_names, const Variant &p_val
|
||||
}
|
||||
|
||||
bool valid = false;
|
||||
if (!r_valid)
|
||||
if (!r_valid) {
|
||||
r_valid = &valid;
|
||||
}
|
||||
|
||||
List<Variant> value_stack;
|
||||
|
||||
@@ -583,8 +615,9 @@ void Object::set_indexed(const Vector<StringName> &p_names, const Variant &p_val
|
||||
|
||||
Variant Object::get_indexed(const Vector<StringName> &p_names, bool *r_valid) const {
|
||||
if (p_names.empty()) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
return Variant();
|
||||
}
|
||||
bool valid = false;
|
||||
@@ -593,11 +626,13 @@ Variant Object::get_indexed(const Vector<StringName> &p_names, bool *r_valid) co
|
||||
for (int i = 1; i < p_names.size(); i++) {
|
||||
current_value = current_value.get_named(p_names[i], &valid);
|
||||
|
||||
if (!valid)
|
||||
if (!valid) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = valid;
|
||||
}
|
||||
|
||||
return current_value;
|
||||
}
|
||||
@@ -767,13 +802,15 @@ bool Object::has_method(const StringName &p_method) const {
|
||||
}
|
||||
|
||||
Variant Object::getvar(const Variant &p_key, bool *r_valid) const {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
return Variant();
|
||||
}
|
||||
void Object::setvar(const Variant &p_key, const Variant &p_value, bool *r_valid) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
Variant Object::callv(const StringName &p_method, const Array &p_args) {
|
||||
@@ -799,8 +836,9 @@ Variant Object::call(const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
|
||||
int argc = 0;
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
if (argptr[i]->get_type() == Variant::NIL)
|
||||
if (argptr[i]->get_type() == Variant::NIL) {
|
||||
break;
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
|
||||
@@ -815,8 +853,9 @@ void Object::call_multilevel(const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
|
||||
int argc = 0;
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
if (argptr[i]->get_type() == Variant::NIL)
|
||||
if (argptr[i]->get_type() == Variant::NIL) {
|
||||
break;
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
|
||||
@@ -896,8 +935,9 @@ String Object::to_string() {
|
||||
if (script_instance) {
|
||||
bool valid;
|
||||
String ret = script_instance->to_string(&valid);
|
||||
if (valid)
|
||||
if (valid) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return "[" + get_class() + ":" + itos(get_instance_id()) + "]";
|
||||
}
|
||||
@@ -962,8 +1002,9 @@ void Object::set_script_and_instance(const RefPtr &p_script, ScriptInstance *p_i
|
||||
}
|
||||
|
||||
void Object::set_script(const RefPtr &p_script) {
|
||||
if (script == p_script)
|
||||
if (script == p_script) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (script_instance) {
|
||||
memdelete(script_instance);
|
||||
@@ -988,18 +1029,21 @@ void Object::set_script(const RefPtr &p_script) {
|
||||
}
|
||||
|
||||
void Object::set_script_instance(ScriptInstance *p_instance) {
|
||||
if (script_instance == p_instance)
|
||||
if (script_instance == p_instance) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (script_instance)
|
||||
if (script_instance) {
|
||||
memdelete(script_instance);
|
||||
}
|
||||
|
||||
script_instance = p_instance;
|
||||
|
||||
if (p_instance)
|
||||
if (p_instance) {
|
||||
script = p_instance->get_script().get_ref_ptr();
|
||||
else
|
||||
} else {
|
||||
script = RefPtr();
|
||||
}
|
||||
}
|
||||
|
||||
RefPtr Object::get_script() const {
|
||||
@@ -1077,8 +1121,9 @@ void Object::add_user_signal(const MethodInfo &p_signal) {
|
||||
}
|
||||
|
||||
bool Object::_has_user_signal(const StringName &p_name) const {
|
||||
if (!signal_map.has(p_name))
|
||||
if (!signal_map.has(p_name)) {
|
||||
return false;
|
||||
}
|
||||
return signal_map[p_name].user.name.length() > 0;
|
||||
}
|
||||
|
||||
@@ -1116,8 +1161,9 @@ Variant Object::_emit_signal(const Variant **p_args, int p_argcount, Variant::Ca
|
||||
}
|
||||
|
||||
Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int p_argcount) {
|
||||
if (_block_signals)
|
||||
if (_block_signals) {
|
||||
return ERR_CANT_ACQUIRE_RESOURCE; //no emit, signals blocked
|
||||
}
|
||||
|
||||
Signal *s = signal_map.getptr(p_name);
|
||||
if (!s) {
|
||||
@@ -1182,8 +1228,9 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
|
||||
|
||||
if (ce.error != Variant::CallError::CALL_OK) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (c.flags & CONNECT_PERSIST && Engine::get_singleton()->is_editor_hint() && (script.is_null() || !Ref<Script>(script)->is_tool()))
|
||||
if (c.flags & CONNECT_PERSIST && Engine::get_singleton()->is_editor_hint() && (script.is_null() || !Ref<Script>(script)->is_tool())) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (ce.error == Variant::CallError::CALL_ERROR_INVALID_METHOD && !ClassDB::class_exists(target->get_class_name())) {
|
||||
//most likely object is not initialized yet, do not throw error.
|
||||
@@ -1225,8 +1272,9 @@ Error Object::emit_signal(const StringName &p_name, VARIANT_ARG_DECLARE) {
|
||||
int argc = 0;
|
||||
|
||||
for (int i = 0; i < VARIANT_ARG_MAX; i++) {
|
||||
if (argptr[i]->get_type() == Variant::NIL)
|
||||
if (argptr[i]->get_type() == Variant::NIL) {
|
||||
break;
|
||||
}
|
||||
argc++;
|
||||
}
|
||||
|
||||
@@ -1245,10 +1293,12 @@ void Object::_add_user_signal(const String &p_name, const Array &p_args) {
|
||||
Dictionary d = p_args[i];
|
||||
PropertyInfo param;
|
||||
|
||||
if (d.has("name"))
|
||||
if (d.has("name")) {
|
||||
param.name = d["name"];
|
||||
if (d.has("type"))
|
||||
}
|
||||
if (d.has("type")) {
|
||||
param.type = (Variant::Type)(int)d["type"];
|
||||
}
|
||||
|
||||
mi.arguments.push_back(param);
|
||||
}
|
||||
@@ -1358,11 +1408,13 @@ void Object::get_all_signal_connections(List<Connection> *p_connections) const {
|
||||
|
||||
void Object::get_signal_connection_list(const StringName &p_signal, List<Connection> *p_connections) const {
|
||||
const Signal *s = signal_map.getptr(p_signal);
|
||||
if (!s)
|
||||
if (!s) {
|
||||
return; //nothing
|
||||
}
|
||||
|
||||
for (int i = 0; i < s->slot_map.size(); i++)
|
||||
for (int i = 0; i < s->slot_map.size(); i++) {
|
||||
p_connections->push_back(s->slot_map.getv(i).conn);
|
||||
}
|
||||
}
|
||||
|
||||
int Object::get_persistent_signal_connection_count() const {
|
||||
@@ -1450,11 +1502,13 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const
|
||||
const Signal *s = signal_map.getptr(p_signal);
|
||||
if (!s) {
|
||||
bool signal_is_valid = ClassDB::has_signal(get_class_name(), p_signal);
|
||||
if (signal_is_valid)
|
||||
if (signal_is_valid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal))
|
||||
if (!script.is_null() && Ref<Script>(script)->has_script_signal(p_signal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ERR_FAIL_V_MSG(false, "Nonexistent signal: " + p_signal + ".");
|
||||
}
|
||||
@@ -1520,16 +1574,18 @@ Variant Object::_get_indexed_bind(const NodePath &p_name) const {
|
||||
|
||||
void Object::initialize_class() {
|
||||
static bool initialized = false;
|
||||
if (initialized)
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
ClassDB::_add_class<Object>();
|
||||
_bind_methods();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
StringName Object::tr(const StringName &p_message) const {
|
||||
if (!_can_translate || !TranslationServer::get_singleton())
|
||||
if (!_can_translate || !TranslationServer::get_singleton()) {
|
||||
return p_message;
|
||||
}
|
||||
|
||||
return TranslationServer::get_singleton()->translate(p_message);
|
||||
}
|
||||
@@ -1538,15 +1594,18 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
|
||||
switch (p_var.get_type()) {
|
||||
case Variant::OBJECT: {
|
||||
RES r = p_var;
|
||||
if (!r.is_valid())
|
||||
if (!r.is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!r->get_path().begins_with("res://") || r->get_path().find("::") == -1)
|
||||
if (!r->get_path().begins_with("res://") || r->get_path().find("::") == -1) {
|
||||
return; //not an internal resource
|
||||
}
|
||||
|
||||
Object *object = p_var;
|
||||
if (!object)
|
||||
if (!object) {
|
||||
return;
|
||||
}
|
||||
|
||||
r->set_path("");
|
||||
r->clear_internal_resource_paths();
|
||||
@@ -1576,10 +1635,11 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
|
||||
#ifdef TOOLS_ENABLED
|
||||
void Object::editor_set_section_unfold(const String &p_section, bool p_unfolded) {
|
||||
set_edited(true);
|
||||
if (p_unfolded)
|
||||
if (p_unfolded) {
|
||||
editor_section_folding.insert(p_section);
|
||||
else
|
||||
} else {
|
||||
editor_section_folding.erase(p_section);
|
||||
}
|
||||
}
|
||||
|
||||
bool Object::editor_is_section_unfolded(const String &p_section) {
|
||||
@@ -1723,13 +1783,15 @@ void Object::get_translatable_strings(List<String> *p_strings) const {
|
||||
get_property_list(&plist);
|
||||
|
||||
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
|
||||
if (!(E->get().usage & PROPERTY_USAGE_INTERNATIONALIZED))
|
||||
if (!(E->get().usage & PROPERTY_USAGE_INTERNATIONALIZED)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String text = get(E->get().name);
|
||||
|
||||
if (text == "")
|
||||
if (text == "") {
|
||||
continue;
|
||||
}
|
||||
|
||||
p_strings->push_back(text);
|
||||
}
|
||||
@@ -1739,24 +1801,27 @@ Variant::Type Object::get_static_property_type(const StringName &p_property, boo
|
||||
bool valid;
|
||||
Variant::Type t = ClassDB::get_property_type(get_class_name(), p_property, &valid);
|
||||
if (valid) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
if (get_script_instance()) {
|
||||
return get_script_instance()->get_property_type(p_property, r_valid);
|
||||
}
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
|
||||
return Variant::NIL;
|
||||
}
|
||||
|
||||
Variant::Type Object::get_static_property_type_indexed(const Vector<StringName> &p_path, bool *r_valid) const {
|
||||
if (p_path.size() == 0) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
|
||||
return Variant::NIL;
|
||||
}
|
||||
@@ -1764,8 +1829,9 @@ Variant::Type Object::get_static_property_type_indexed(const Vector<StringName>
|
||||
bool valid = false;
|
||||
Variant::Type t = get_static_property_type(p_path[0], &valid);
|
||||
if (!valid) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
|
||||
return Variant::NIL;
|
||||
}
|
||||
@@ -1776,22 +1842,25 @@ Variant::Type Object::get_static_property_type_indexed(const Vector<StringName>
|
||||
for (int i = 1; i < p_path.size(); i++) {
|
||||
if (check.get_type() == Variant::OBJECT || check.get_type() == Variant::DICTIONARY || check.get_type() == Variant::ARRAY) {
|
||||
// We cannot be sure about the type of properties this types can have
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
return Variant::NIL;
|
||||
}
|
||||
|
||||
check = check.get_named(p_path[i], &valid);
|
||||
|
||||
if (!valid) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
return Variant::NIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
|
||||
return check.get_type();
|
||||
}
|
||||
@@ -1882,8 +1951,9 @@ Object::~Object() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (script_instance)
|
||||
if (script_instance) {
|
||||
memdelete(script_instance);
|
||||
}
|
||||
script_instance = nullptr;
|
||||
|
||||
const StringName *S = nullptr;
|
||||
@@ -1963,8 +2033,9 @@ Object *ObjectDB::get_instance(ObjectID p_instance_id) {
|
||||
Object **obj = instances.getptr(p_instance_id);
|
||||
rw_lock.read_unlock();
|
||||
|
||||
if (!obj)
|
||||
if (!obj) {
|
||||
return nullptr;
|
||||
}
|
||||
return *obj;
|
||||
}
|
||||
|
||||
@@ -2007,10 +2078,12 @@ void ObjectDB::cleanup() {
|
||||
const ObjectID *K = nullptr;
|
||||
while ((K = instances.next(K))) {
|
||||
String extra_info;
|
||||
if (instances[*K]->is_class("Node"))
|
||||
if (instances[*K]->is_class("Node")) {
|
||||
extra_info = " - Node name: " + String(node_get_name->call(instances[*K], nullptr, 0, call_error));
|
||||
if (instances[*K]->is_class("Resource"))
|
||||
}
|
||||
if (instances[*K]->is_class("Resource")) {
|
||||
extra_info = " - Resource path: " + String(resource_get_path->call(instances[*K], nullptr, 0, call_error));
|
||||
}
|
||||
print_line("Leaked instance: " + String(instances[*K]->get_class()) + ":" + itos(*K) + extra_info);
|
||||
}
|
||||
print_line("Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).");
|
||||
|
||||
Reference in New Issue
Block a user