diff --git a/components/rtgui/common/dc_client.c b/components/rtgui/common/dc_client.c index 6dcf3181c04080b669f27edff4a3d842657d527b..15360501c92bf296f0ffcb61d8f64e7489d634a7 100644 --- a/components/rtgui/common/dc_client.c +++ b/components/rtgui/common/dc_client.c @@ -42,6 +42,8 @@ static void rtgui_dc_client_get_rect(struct rtgui_dc* dc, rtgui_rect_t* rect); struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner) { + RT_ASSERT(owner != RT_NULL); + if ((rtgui_region_is_flat(&owner->clip) == RT_EOK) && rtgui_rect_is_equal(&(owner->extent), &(owner->clip.extents)) == RT_EOK) { diff --git a/components/rtgui/common/rtgui_theme.c b/components/rtgui/common/rtgui_theme.c index 266ceea9c91793859545f07d9039e69e91283078..e328f19f0bac44dfc542fe93ce18bd5a180b3862 100644 --- a/components/rtgui/common/rtgui_theme.c +++ b/components/rtgui/common/rtgui_theme.c @@ -58,6 +58,8 @@ void rtgui_theme_draw_win(struct rtgui_topwin* win) struct rtgui_dc* dc; rtgui_rect_t rect; + if (win->title == RT_NULL) return; /* no title and no board */ + /* begin drawing */ dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(win->title)); if (dc == RT_NULL) return; diff --git a/components/rtgui/widgets/widget.c b/components/rtgui/widgets/widget.c index 81968f929d18aa6fda456150761171443b0391ce..34b022c04a7e0fd40553f63c62ebe12fe2a53795 100644 --- a/components/rtgui/widgets/widget.c +++ b/components/rtgui/widgets/widget.c @@ -134,7 +134,7 @@ void rtgui_widget_set_rect(rtgui_widget_t* widget, rtgui_rect_t* rect) if ((widget->parent != RT_NULL) && (widget->toplevel != RT_NULL)) { /* update widget clip */ - rtgui_widget_update_clip(widget); + rtgui_widget_update_clip(widget->parent); } } @@ -417,7 +417,15 @@ void rtgui_widget_update_clip(rtgui_widget_t* widget) parent = widget->parent; /* if there is no parent, do not update clip (please use toplevel widget API) */ - if (parent == RT_NULL) return; + if (parent == RT_NULL) + { + if (RTGUI_IS_TOPLEVEL(widget)) + { + /* if it's toplevel widget, update it by toplevel function */ + rtgui_toplevel_update_clip(RTGUI_TOPLEVEL(widget)); + } + return; + } /* reset clip to extent */ rtgui_region_reset(&(widget->clip), &(widget->extent));