Add various null checks in RenderingServer

This commit is contained in:
Haoyu Qiu 2022-09-30 09:55:32 +08:00
parent 56563ef09e
commit ffdac72eaa
5 changed files with 10 additions and 0 deletions

View file

@ -666,6 +666,8 @@ void TextureStorage::texture_free(RID p_texture) {
}
void TextureStorage::texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) {
ERR_FAIL_COND(p_image.is_null());
Texture texture;
texture.width = p_image->get_width();
texture.height = p_image->get_height();

View file

@ -170,6 +170,10 @@ void RendererCompositorRD::finalize() {
}
void RendererCompositorRD::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
if (p_image.is_null() || p_image->is_empty()) {
return;
}
RD::get_singleton()->prepare_screen_for_drawing();
RID texture = texture_storage->texture_allocate();

View file

@ -3621,6 +3621,7 @@ TypedArray<Image> RendererSceneRenderRD::bake_render_uv2(RID p_base, const Typed
//RID sampled_light;
RenderGeometryInstance *gi = geometry_instance_create(p_base);
ERR_FAIL_NULL_V(gi, TypedArray<Image>());
uint32_t sc = RSG::mesh_storage->mesh_get_surface_count(p_base);
Vector<RID> materials;

View file

@ -2021,6 +2021,7 @@ Transform2D MeshStorage::skeleton_bone_get_transform_2d(RID p_skeleton, int p_bo
void MeshStorage::skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) {
Skeleton *skeleton = skeleton_owner.get_or_null(p_skeleton);
ERR_FAIL_NULL(skeleton);
ERR_FAIL_COND(!skeleton->use_2d);
skeleton->base_transform_2d = p_base_transform;

View file

@ -673,6 +673,8 @@ void TextureStorage::texture_free(RID p_texture) {
}
void TextureStorage::texture_2d_initialize(RID p_texture, const Ref<Image> &p_image) {
ERR_FAIL_COND(p_image.is_null());
TextureToRDFormat ret_format;
Ref<Image> image = _validate_texture_format(p_image, ret_format);