From c6f0cf50caa0a310ff9dc3f1533302cce269ea90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 28 Jul 2023 22:57:02 +0200 Subject: [PATCH] Use better safety in rectangular grid - Checking `DrawSize != Vector2.Zero` is too specific. It could also crash on zero-height-but-non-zero-width, or zero-width-but-non-zero-height. - Take the `gridCache.Validate()` call out of the zero checks, because even if the width or height are zero, not generating anything is valid and there is no reason to validate every frame until `gridCache` gets invalidated again. --- .../Edit/Compose/Components/RectangularPositionSnapGrid.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs b/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs index bec1d148be..cfc01fe17b 100644 --- a/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs +++ b/osu.Game/Screens/Edit/Compose/Components/RectangularPositionSnapGrid.cs @@ -55,11 +55,10 @@ namespace osu.Game.Screens.Edit.Compose.Components { ClearInternal(); - if (DrawSize != Vector2.Zero) - { + if (DrawWidth > 0 && DrawHeight > 0) createContent(); - gridCache.Validate(); - } + + gridCache.Validate(); } }