uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 05356e23b17441d7f134b0ab5b4c8c89c483293f
parent ff6d9e39caf6774ae2c49c8ba91d4efb59b49bd7
Author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
Date:   Mon, 10 Jul 2023 15:35:35 +0000

capture_screen: check for errors

Diffstat:
Msrc/uxnemu.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -289,13 +289,15 @@ capture_screen(void) int w, h; SDL_Surface *surface; SDL_GetRendererOutputSize(emu_renderer, &w, &h); - surface = SDL_CreateRGBSurface(0, w, h, 24, Rmask, Gmask, Bmask, 0); + if((surface = SDL_CreateRGBSurface(0, w, h, 24, Rmask, Gmask, Bmask, 0)) == NULL) + return; SDL_RenderReadPixels(emu_renderer, NULL, format, surface->pixels, surface->pitch); strftime(fname, sizeof(fname), "screenshot-%Y%m%d-%H%M%S.bmp", localtime(&t)); - SDL_SaveBMP(surface, fname); + if(SDL_SaveBMP(surface, fname) == 0){ + fprintf(stderr, "Saved %s\n", fname); + fflush(stderr); + } SDL_FreeSurface(surface); - fprintf(stderr, "Saved %s\n", fname); - fflush(stderr); } static void