mirror of
https://github.com/godotengine/godot.git
synced 2024-12-09 10:09:20 +08:00
Merge pull request #66551 from bruvzg/font_is_cyclic
Fix Font::_is_cyclic.
This commit is contained in:
commit
67f79819e7
@ -127,16 +127,18 @@ void Font::_invalidate_rids() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Font::_is_cyclic(const Ref<Font> &p_f, int p_depth) const {
|
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()) {
|
if (p_f.is_null()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (p_f == this) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
for (int i = 0; i < p_f->fallbacks.size(); i++) {
|
for (int i = 0; i < p_f->fallbacks.size(); i++) {
|
||||||
const Ref<Font> &f = p_f->fallbacks[i];
|
const Ref<Font> &f = p_f->fallbacks[i];
|
||||||
if (f == this) {
|
if (_is_cyclic(f, p_depth + 1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return _is_cyclic(f, p_depth + 1);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -147,7 +149,10 @@ void Font::reset_state() {
|
|||||||
|
|
||||||
// Fallbacks.
|
// Fallbacks.
|
||||||
void Font::set_fallbacks(const TypedArray<Font> &p_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++) {
|
for (int i = 0; i < fallbacks.size(); i++) {
|
||||||
Ref<Font> f = fallbacks[i];
|
Ref<Font> f = fallbacks[i];
|
||||||
if (f.is_valid()) {
|
if (f.is_valid()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user