From c796a4b28603e75d522e0711eeb4596ea43d868a Mon Sep 17 00:00:00 2001 From: idea4good Date: Thu, 10 Jan 2019 15:05:08 +0800 Subject: [PATCH] add valid check for wav_ctrl --- core/src/surface.cpp | 1 - core/src/wave_ctrl.cpp | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/surface.cpp b/core/src/surface.cpp index 4918086..0ed3133 100644 --- a/core/src/surface.cpp +++ b/core/src/surface.cpp @@ -594,7 +594,6 @@ void c_surface_mcu::fill_rect(int x0, int y0, int x1, int y1, unsigned int rgb, { return m_gfx_op->fill_rect(x0, y0, x1, y1, rgb); } - for (; y0 <= y1; y0++) { draw_hline(x0, x1, y0, rgb, z_order); diff --git a/core/src/wave_ctrl.cpp b/core/src/wave_ctrl.cpp index 70b471c..07f78ec 100644 --- a/core/src/wave_ctrl.cpp +++ b/core/src/wave_ctrl.cpp @@ -258,16 +258,18 @@ void c_wave_ctrl::restore_background() register int width = rect.Width(); register int top = rect.m_top; register int left = rect.m_left; - unsigned int* p_fb = m_bg_fb; - for (int y_pos = (m_wave_top - 1); y_pos <= (m_wave_bottom + 1); y_pos++) { - draw_pixel(x, y_pos, p_fb[(y_pos - top) * width + (x - left)]); + (m_bg_fb) ? draw_pixel(x, y_pos, m_bg_fb[(y_pos - top) * width + (x - left)]) : draw_pixel(x, y_pos, 0); } } void c_wave_ctrl::save_background() { + if (!m_bg_fb) + { + return; + } c_rect rect; get_screen_rect(rect);