summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-09-28 20:47:56 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-09-28 20:47:56 +0200
commit67f79819e79a7cd40832baf4f7ee78907beef927 (patch)
tree4ad29cd2fea3b40d219a43c143449340b9b65555 /scene
parente5857bd6c79e9201d8f49ac335b2da9142afc39c (diff)
parent155694c7c68fc4b0bb54e4e075d945abbba39fa4 (diff)
Merge pull request #66551 from bruvzg/font_is_cyclic
Fix Font::_is_cyclic.
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/font.cpp13
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()) {