diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-09-28 17:47:34 +0300 |
---|---|---|
committer | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2022-09-28 18:11:17 +0300 |
commit | 155694c7c68fc4b0bb54e4e075d945abbba39fa4 (patch) | |
tree | 6fce613b5bbae80020ab4891b6ce5e9ce642f639 | |
parent | 14e1f36e614686f3fea0c74fac3624d1027dd5cc (diff) |
Fix Font::_is_cyclic.
-rw-r--r-- | scene/resources/font.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index bbc4029764..410bbdbb40 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -127,16 +127,18 @@ void Font::_invalidate_rids() { } bool Font::_is_cyclic(const Ref<Font> &p_f, int p_depth) const { - ERR_FAIL_COND_V(p_depth > MAX_FALLBACK_DEPTH, false); + ERR_FAIL_COND_V(p_depth > MAX_FALLBACK_DEPTH, true); if (p_f.is_null()) { return false; } + if (p_f == this) { + return true; + } for (int i = 0; i < p_f->fallbacks.size(); i++) { const Ref<Font> &f = p_f->fallbacks[i]; - if (f == this) { + if (_is_cyclic(f, p_depth + 1)) { return true; } - return _is_cyclic(f, p_depth + 1); } return false; } @@ -147,7 +149,10 @@ void Font::reset_state() { // Fallbacks. void Font::set_fallbacks(const TypedArray<Font> &p_fallbacks) { - ERR_FAIL_COND(_is_cyclic(this, 0)); + for (int i = 0; i < p_fallbacks.size(); i++) { + const Ref<Font> &f = p_fallbacks[i]; + ERR_FAIL_COND_MSG(_is_cyclic(f, 0), "Cyclic font fallback."); + } for (int i = 0; i < fallbacks.size(); i++) { Ref<Font> f = fallbacks[i]; if (f.is_valid()) { |