Commit 352c23b6 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Waveform: fix crash when enabled outside ML menu

(e.g. from Lua, https://www.magiclantern.fm/forum/index.php?topic=23673)

Issue: initialization on first use + race condition.

--HG--
branch : lua_fix
parent abdd1e22512f
...@@ -505,6 +505,7 @@ static void hist_add_pixel(uint32_t pixel, int Y) ...@@ -505,6 +505,7 @@ static void hist_add_pixel(uint32_t pixel, int Y)
#ifdef FEATURE_WAVEFORM #ifdef FEATURE_WAVEFORM
static inline void waveform_add_pixel(int x, int Y) static inline void waveform_add_pixel(int x, int Y)
{ {
if (!waveform) return;
uint8_t* w = &WAVEFORM(((x-os.x0) * WAVEFORM_WIDTH) / os.x_ex, (Y * WAVEFORM_HEIGHT) >> 8); uint8_t* w = &WAVEFORM(((x-os.x0) * WAVEFORM_WIDTH) / os.x_ex, (Y * WAVEFORM_HEIGHT) >> 8);
if ((*w) < 250) (*w)++; if ((*w) < 250) (*w)++;
} }
...@@ -941,6 +942,8 @@ waveform_draw_image( ...@@ -941,6 +942,8 @@ waveform_draw_image(
unsigned height unsigned height
) )
{ {
if (!waveform) return;
if (!PLAY_OR_QR_MODE) if (!PLAY_OR_QR_MODE)
{ {
if (!lv_luma_is_accurate()) return; if (!lv_luma_is_accurate()) return;
...@@ -3732,7 +3735,7 @@ void draw_histogram_and_waveform(int allow_play) ...@@ -3732,7 +3735,7 @@ void draw_histogram_and_waveform(int allow_play)
if (is_zoom_mode_so_no_zebras()) return; if (is_zoom_mode_so_no_zebras()) return;
#ifdef FEATURE_WAVEFORM #ifdef FEATURE_WAVEFORM
if( waveform_draw) if (waveform_draw)
{ {
#ifdef CONFIG_4_3_SCREEN #ifdef CONFIG_4_3_SCREEN
if (PLAY_OR_QR_MODE && WAVEFORM_FACTOR == 1) if (PLAY_OR_QR_MODE && WAVEFORM_FACTOR == 1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment