Skip to content

Commit

Permalink
Fix SpriteBatch leak when error handler player sprite fails to render
Browse files Browse the repository at this point in the history
  • Loading branch information
Popax21 committed Aug 4, 2023
1 parent 8f33dab commit 2e4c8ff
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Celeste.Mod.mm/Mod/UI/CriticalErrorHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,13 @@ private void BeforeRender() {
Celeste.Instance.GraphicsDevice.Clear(Color.Transparent);
Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateTranslation(16, 32, 0));

playerHair.AfterUpdate();
playerHair.Render();
playerSprite.Render();

Draw.SpriteBatch.End();
try {
playerHair.AfterUpdate();
playerHair.Render();
playerSprite.Render();
} finally {
Draw.SpriteBatch.End();
}
} catch (Exception ex) {
Logger.Log(LogLevel.Error, "crit-error-handler", "Error while rendering player sprite:");
Logger.LogDetailed(ex, "crit-error-handler");
Expand Down

0 comments on commit 2e4c8ff

Please sign in to comment.