Core: Fix recursion level check for array stringification
This commit is contained in:
parent
aa353df8cb
commit
bb40bd9aaa
|
@ -1754,11 +1754,10 @@ String Variant::stringify(int recursion_count) const {
|
|||
case COLOR:
|
||||
return operator Color();
|
||||
case DICTIONARY: {
|
||||
ERR_FAIL_COND_V_MSG(recursion_count > MAX_RECURSION, "{ ... }", "Maximum dictionary recursion reached!");
|
||||
recursion_count++;
|
||||
|
||||
const Dictionary &d = *reinterpret_cast<const Dictionary *>(_data._mem);
|
||||
if (recursion_count > MAX_RECURSION) {
|
||||
ERR_PRINT("Maximum dictionary recursion reached!");
|
||||
return "{ ... }";
|
||||
}
|
||||
|
||||
// Add leading and trailing space to Dictionary printing. This distinguishes it
|
||||
// from array printing on fonts that have similar-looking {} and [] characters.
|
||||
|
@ -1768,7 +1767,6 @@ String Variant::stringify(int recursion_count) const {
|
|||
|
||||
Vector<_VariantStrPair> pairs;
|
||||
|
||||
recursion_count++;
|
||||
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
|
||||
_VariantStrPair sp;
|
||||
sp.key = stringify_variant_clean(E->get(), recursion_count);
|
||||
|
@ -1787,6 +1785,7 @@ String Variant::stringify(int recursion_count) const {
|
|||
|
||||
return str;
|
||||
}
|
||||
// Packed arrays cannot contain recursive structures, the recursion_count increment is not needed.
|
||||
case PACKED_VECTOR2_ARRAY: {
|
||||
return stringify_vector(operator Vector<Vector2>(), recursion_count);
|
||||
}
|
||||
|
@ -1815,13 +1814,10 @@ String Variant::stringify(int recursion_count) const {
|
|||
return stringify_vector(operator Vector<double>(), recursion_count);
|
||||
}
|
||||
case ARRAY: {
|
||||
Array arr = operator Array();
|
||||
if (recursion_count > MAX_RECURSION) {
|
||||
ERR_PRINT("Maximum array recursion reached!");
|
||||
return "[...]";
|
||||
}
|
||||
ERR_FAIL_COND_V_MSG(recursion_count > MAX_RECURSION, "[...]", "Maximum array recursion reached!");
|
||||
recursion_count++;
|
||||
|
||||
return stringify_vector(arr, recursion_count);
|
||||
return stringify_vector(operator Array(), recursion_count);
|
||||
}
|
||||
case OBJECT: {
|
||||
if (_get_obj().obj) {
|
||||
|
|
Loading…
Reference in New Issue