From 97568be2c1b87430243b9fc410b28c1b361e063d Mon Sep 17 00:00:00 2001 From: pommicket Date: Wed, 26 Feb 2025 12:08:29 -0500 Subject: Fix crash switching to video mode with no camera connected --- README.md | 1 + main.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2530caf..9e9fa71 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ You can try deleting/renaming your settings file as a temporary solution, to res +
Version Description Date
0.0.0 Initial release 2025 Feb 26
0.0.1 Fix crash switching to video mode with no camera connected 2025 Feb 26
## License diff --git a/main.c b/main.c index 603c8ad..4fc4a8f 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -#define VERSION "0.0.0" +#define VERSION "0.0.1" #define _GNU_SOURCE #include @@ -1378,9 +1378,11 @@ void main() {\n\ if (state->curr_menu) break; if (video_is_recording(state->video)) break; state->mode = (state->mode + 1) % MODE_COUNT; - // picture format may be different now - PictureFormat picfmt = settings_picture_format_for_camera(state, state->camera); - camera_set_format(state->camera, picfmt, settings_desired_framerate(state), 0, false); + if (state->camera) { + // picture format may be different now + PictureFormat picfmt = settings_picture_format_for_camera(state, state->camera); + camera_set_format(state->camera, picfmt, settings_desired_framerate(state), 0, false); + } break; case SDLK_SPACE: if (!state->camera || state->curr_menu != 0) break; -- cgit v1.2.3