Merge pull request #73000 from Sauermann/fix-editor-viewport-size-zero-crash

Fix crash in editor when setting `SubViewport.size` to zero
This commit is contained in:
Rémi Verschelde 2023-02-10 15:06:57 +01:00
commit 97afa41da3
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 4 additions and 3 deletions

View File

@ -823,11 +823,12 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override,
stretch_transform_new.scale(scale);
}
if (size == p_size && size_allocated == p_allocated && stretch_transform == stretch_transform_new && p_size_2d_override == size_2d_override) {
Size2i new_size = p_size.max(Size2i(2, 2));
if (size == new_size && size_allocated == p_allocated && stretch_transform == stretch_transform_new && p_size_2d_override == size_2d_override) {
return;
}
size = p_size;
size = new_size;
size_allocated = p_allocated;
size_2d_override = p_size_2d_override;
stretch_transform = stretch_transform_new;

View File

@ -844,7 +844,7 @@ void RendererViewport::viewport_set_scaling_3d_scale(RID p_viewport, float p_sca
}
void RendererViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) {
ERR_FAIL_COND(p_width < 0 && p_height < 0);
ERR_FAIL_COND(p_width < 0 || p_height < 0);
Viewport *viewport = viewport_owner.get_or_null(p_viewport);
ERR_FAIL_COND(!viewport);