Skip to content

FlxGridOverlay: Prevent freeze when passing invalid cell size values#462

Merged
Geokureli merged 3 commits into
HaxeFlixel:devfrom
ACrazyTown:fix/flxgridoverlay-freeze
Jun 30, 2025
Merged

FlxGridOverlay: Prevent freeze when passing invalid cell size values#462
Geokureli merged 3 commits into
HaxeFlixel:devfrom
ACrazyTown:fix/flxgridoverlay-freeze

Conversation

@ACrazyTown
Copy link
Copy Markdown
Contributor

Passing in 0 or a negative number (in my case due to a bad calculation) when creating a grid overlay caused the while loops in createGrid() to never exit because x/y would always be smaller than width/height

@Geokureli
Copy link
Copy Markdown
Member

Geokureli commented Jun 26, 2025

I'm not familiar with this class, is there an example usage somewhere?

Also, does it make sense to throw or log an error in this case?

My immediate thought is to throw, since logs won't be seen until the next update, which may be after some other call already caused an error or infinite loop

@Geokureli
Copy link
Copy Markdown
Member

Also, I don't recommend using this class, lol. this seems outdated and optimized for Flash rather than renderTile targets. I'm still okay with the PR, but yeah I think this class should be replaced and deprecated

@ACrazyTown
Copy link
Copy Markdown
Contributor Author

I'm not familiar with this class, is there an example usage somewhere?
It's just a quick and easy helper to create a grid.

var bg = FlxGridOverlay.create(10, 10);
add(bg);

This returns an FlxSprite the size of the game with a grid graphic that has 10x10 sized cells.

Also, does it make sense to throw or log an error in this case?
My immediate thought is to throw, since logs won't be seen until the next update, which may be after some other call already caused an error or infinite loop

Yeah throwing is likely better here

@Geokureli Geokureli merged commit dcd3895 into HaxeFlixel:dev Jun 30, 2025
10 checks passed
@Geokureli Geokureli added this to the 4.0.0 milestone Jun 30, 2025
@Geokureli Geokureli added the Bug label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants