summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2025-02-26 12:08:29 -0500
committerpommicket <pommicket@gmail.com>2025-02-26 12:08:29 -0500
commit97568be2c1b87430243b9fc410b28c1b361e063d (patch)
treed7cd9aca7143490de1f9961fa947e994b8759184
parent700c0f803c933522166f9a91073040f204ca32b6 (diff)
Fix crash switching to video mode with no camera connected0.0.1
-rw-r--r--README.md1
-rw-r--r--main.c10
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
<table>
<tr><th>Version</th> <th>Description</th> <th>Date</th></tr>
<tr><td>0.0.0</td> <td>Initial release</td> <td>2025 Feb 26</td></tr>
+<tr><td>0.0.1</td> <td>Fix crash switching to video mode with no camera connected</td> <td>2025 Feb 26</td></tr>
</table>
## 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 <stdio.h>
@@ -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;