Fix crash when trying to set fallback or next pass with one of parent
This commit is contained in:
parent
7b67c5857f
commit
4270403724
2 changed files with 13 additions and 2 deletions
|
@ -497,7 +497,13 @@ Size2 Font::get_string_size(const String &p_string) const {
|
|||
}
|
||||
void BitmapFont::set_fallback(const Ref<BitmapFont> &p_fallback) {
|
||||
|
||||
ERR_FAIL_COND(p_fallback == this);
|
||||
for (Ref<BitmapFont> fallback_child = p_fallback; fallback_child != NULL; fallback_child = fallback_child->get_fallback()) {
|
||||
if (fallback_child == this) {
|
||||
ERR_EXPLAIN("Can't set as fallback one of its parents to prevent crashes due to recursive loop.");
|
||||
ERR_FAIL_COND(fallback_child == this);
|
||||
}
|
||||
}
|
||||
|
||||
fallback = p_fallback;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,12 @@
|
|||
|
||||
void Material::set_next_pass(const Ref<Material> &p_pass) {
|
||||
|
||||
ERR_FAIL_COND(p_pass == this);
|
||||
for (Ref<Material> pass_child = p_pass; pass_child != NULL; pass_child = pass_child->get_next_pass()) {
|
||||
if (pass_child == this) {
|
||||
ERR_EXPLAIN("Can't set as next_pass one of its parents to prevent crashes due to recursive loop.");
|
||||
ERR_FAIL_COND(pass_child == this);
|
||||
}
|
||||
}
|
||||
|
||||
if (next_pass == p_pass)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue