Browse Source

fix view and workbench destroy issue.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@943 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong@gmail.com 14 years ago
parent
commit
bddae69d9c
2 changed files with 14 additions and 10 deletions
  1. 11 7
      components/rtgui/server/server.c
  2. 3 3
      components/rtgui/widgets/workbench.c

+ 11 - 7
components/rtgui/server/server.c

@@ -136,7 +136,6 @@ void rtgui_server_thread_panel_hide(struct rtgui_event_panel_hide* event)
 	if (panel != RT_NULL)
 	{
 		rt_thread_t tid;
-		struct rtgui_event_paint epaint;
 
 		/* send the responses */
 		rtgui_thread_ack(RTGUI_EVENT(event), RTGUI_STATUS_OK);
@@ -153,15 +152,20 @@ void rtgui_server_thread_panel_hide(struct rtgui_event_panel_hide* event)
 			rtgui_list_append(&(panel->thread_list), &(thread->list));
 		}
 
-		/* get new active thread */
-		tid = rtgui_panel_get_active_thread(panel);
 		/* send all topwin clip info */
 		rtgui_topwin_update_clip_to_panel(panel);
 
-		/* send paint event */
-		RTGUI_EVENT_PAINT_INIT(&epaint);
-		epaint.wid = RT_NULL;
-		rtgui_thread_send(tid, (struct rtgui_event*)&epaint, sizeof(epaint));
+		/* get new active thread */
+		tid = rtgui_panel_get_active_thread(panel);
+		if (tid != RT_NULL)
+		{
+			struct rtgui_event_paint epaint;
+
+			/* send paint event */
+			RTGUI_EVENT_PAINT_INIT(&epaint);
+			epaint.wid = RT_NULL;
+			rtgui_thread_send(tid, (struct rtgui_event*)&epaint, sizeof(epaint));
+		}
 	}
 	else
 	{

+ 3 - 3
components/rtgui/widgets/workbench.c

@@ -135,9 +135,6 @@ void rtgui_workbench_destroy(rtgui_workbench_t* workbench)
 {
 	RT_ASSERT(workbench != RT_NULL);
 
-	/* hide workbench firstly */
-	rtgui_workbench_hide(workbench);
-
 	if (RTGUI_TOPLEVEL(workbench)->server != RT_NULL)
 	{
 		struct rtgui_event_panel_detach edetach;
@@ -398,6 +395,9 @@ rt_bool_t rtgui_workbench_event_handler(rtgui_widget_t* widget, rtgui_event_t* e
 			{
 				rtgui_view_t* view;
 
+				/* un-hide workbench */
+				RTGUI_WIDGET_UNHIDE(widget);
+
 				/* paint a view */
 				view = workbench->current_view;
 				if (view != RT_NULL)