Add some code changes/fixes proposed by Coverity and Clang Tidy

This commit is contained in:
qarmin
2019-08-07 12:54:30 +02:00
parent 045ab51ae5
commit e0b5b21863
26 changed files with 65 additions and 58 deletions

View File

@@ -1021,7 +1021,7 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
if (!unique) {
node_hrcr_count.ref();
ERR_FAIL_COND(!node_hrcr_count.ref());
String name = "@" + String(p_child->get_name()) + "@" + itos(node_hrcr_count.get());
p_child->data.name = name;
}
@@ -2198,8 +2198,11 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
ERR_EXPLAIN("Node: Could not duplicate: " + String(get_class()));
ERR_FAIL_COND(!obj);
node = Object::cast_to<Node>(obj);
if (!node)
if (!node) {
memdelete(obj);
ERR_EXPLAIN("Node: Could not duplicate: " + String(get_class()));
ERR_FAIL();
}
}
List<PropertyInfo> plist;
@@ -2295,16 +2298,16 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
ERR_FAIL_COND_V(get_filename() != "", NULL);
Node *node = NULL;
Object *obj = ClassDB::instance(get_class());
ERR_EXPLAIN("Node: Could not duplicate: " + String(get_class()));
ERR_FAIL_COND_V(!obj, NULL);
node = Object::cast_to<Node>(obj);
if (!node)
memdelete(obj);
ERR_FAIL_COND_V(!node, NULL);
Node *node = Object::cast_to<Node>(obj);
if (!node) {
memdelete(obj);
ERR_EXPLAIN("Node: Could not duplicate: " + String(get_class()));
ERR_FAIL_V(NULL);
}
node->set_name(get_name());
List<PropertyInfo> plist;