Skip to content

fix(console): make use_canvas exception-safe (C2)#37

Merged
dsent merged 2 commits into
aldum:devfrom
Vadim1987:Vadim1987/fix-use-canvas-exception-safe
Jun 30, 2026
Merged

fix(console): make use_canvas exception-safe (C2)#37
dsent merged 2 commits into
aldum:devfrom
Vadim1987:Vadim1987/fix-use-canvas-exception-safe

Conversation

@Vadim1987

Copy link
Copy Markdown

use_canvas bound the offscreen canvas, called f(), then restored with gfx.setCanvas(). If f() threw, the restore was skipped and all later rendering went to the offscreen canvas. Run f() under pcall, always restore the canvas, then re-raise on failure and return f()'s values on success. Error propagation and return values are preserved; only the cleanup is now guaranteed.

@dsent
dsent requested a review from aldum June 30, 2026 02:47

@aldum aldum left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I was the one who left it off, but let's indicate the return type on the method

@Vadim1987

Copy link
Copy Markdown
Author

Good catch — added the @return annotation (any ..., since it forwards f()'s values). Pushed.

@dsent
dsent merged commit 1a0261c into aldum:dev Jun 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants