Skip to content

Commit

Permalink
Fix for godotengine#24534 GDScript Dynamic properties are unacessable…
Browse files Browse the repository at this point in the history
… with dot operator.

Dynamic properties were always accessable with '.' dot operator. Just fixed false error when property name were not checked for presence in  '_get_property_list' godotengine#24534
  • Loading branch information
iiiCpu committed Jul 13, 2021
1 parent 9d2cbe2 commit 713ffa8
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions modules/gdscript/gdscript_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,21 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a

#ifdef DEBUG_ENABLED
if (!valid) {
String err_type;
err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'.";
OPCODE_BREAK;
String _index = String(*index);
List<PropertyInfo> property_list;
dst->get_property_list(&property_list);
bool _has = false;
for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
if (E->get().name == _index) {
_has = true;
break;
}
}
if (!_has) {
String err_type;
err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'.";
OPCODE_BREAK;
}
}
#endif
ip += 4;
Expand Down Expand Up @@ -643,7 +655,19 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
if (src->has_method(*index)) {
err_text = "Invalid get index '" + index->operator String() + "' (on base: '" + _get_var_type(src) + "'). Did you mean '." + index->operator String() + "()' or funcref(obj, \"" + index->operator String() + "\") ?";
} else {
err_text = "Invalid get index '" + index->operator String() + "' (on base: '" + _get_var_type(src) + "').";
String _index = index->operator String();
List<PropertyInfo> property_list;
src->get_property_list(&property_list);
bool has = false;
for (List<PropertyInfo>::Element *E = property_list.front(); E; E = E->next()) {
if (E->get().name == _index) {
has = true;
break;
}
}
if (!has) {
err_text = "Invalid get index '" + index->operator String() + "' (on base: '" + _get_var_type(src) + "').";
}
}
OPCODE_BREAK;
}
Expand Down

0 comments on commit 713ffa8

Please sign in to comment.