mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Convert Object::cast_to() to the static version
Currently we rely on some undefined behavior when Object->cast_to() gets called with a Null pointer. This used to work fine with GCC < 6 but newer versions of GCC remove all codepaths in which the this pointer is Null. However, the non-static cast_to() was supposed to be null safe. This patch makes cast_to() Null safe and removes the now redundant Null checks where they existed. It is explained in this article: https://www.viva64.com/en/b/0226/
This commit is contained in:
@@ -1030,14 +1030,13 @@ RES ResourceFormatLoaderTheme::load(const String &p_path, const String &p_origin
|
||||
ERR_FAIL_V(RES());
|
||||
}
|
||||
|
||||
if (res->cast_to<StyleBox>()) {
|
||||
|
||||
if (Object::cast_to<StyleBox>(*res)) {
|
||||
theme->set_stylebox(item, control, res);
|
||||
} else if (res->cast_to<Font>()) {
|
||||
} else if (Object::cast_to<Font>(*res)) {
|
||||
theme->set_font(item, control, res);
|
||||
} else if (res->cast_to<Font>()) {
|
||||
} else if (Object::cast_to<Font>(*res)) {
|
||||
theme->set_font(item, control, res);
|
||||
} else if (res->cast_to<Texture>()) {
|
||||
} else if (Object::cast_to<Texture>(*res)) {
|
||||
theme->set_icon(item, control, res);
|
||||
} else {
|
||||
memdelete(f);
|
||||
|
||||
Reference in New Issue
Block a user