[58/66] Separate out data window

Message ID 20190624184841.3492-9-tom@tromey.com
State New
Headers show
Series
  • Clean up the TUI
Related show

Commit Message

Tom Tromey June 24, 2019, 6:48 p.m.
This removes "data_window" from union tui_which_element and updates
the uses.  It also changes how tui_data_window refers to the register
data, and changes it not to need the "content" field at all (though as
this is in a base class, it can't yet be removed).

2019-06-23  Tom Tromey  <tom@tromey.com>

	* tui/tui-wingeneral.c (tui_data_window::refresh_window): Update.
	* tui/tui-windata.c (tui_data_window::first_data_item_displayed)
	(tui_delete_data_content_windows, tui_display_all_data)
	(tui_data_window::do_scroll_vertical, tui_display_data_from):
	Update.
	* tui/tui-win.c (tui_data_window::set_new_height): Simplify.
	* tui/tui-regs.c (tui_last_regs_line_no)
	(tui_line_from_reg_element_no, tui_first_reg_element_no_inline)
	(tui_show_registers): Update.
	(tui_show_register_group): Return void.  Update.
	(tui_display_registers_from, tui_display_reg_element_at_line)
	(tui_display_registers_from_line, tui_check_register_values):
	Update.
	* tui/tui-data.h (union tui_which_element) <data_window>: Remove
	member.
	(struct tui_data_window) <regs_content>: Now a std::vector.
	<regs_content_count>: Remove.
	(tui_add_content_elements, tui_free_data_content): Don't declare.
	* tui/tui-data.c (tui_data_window::clear_detail): Update.
	(init_content_element): Remove DATA_WIN case.  Add assert.
	(tui_add_content_elements): Remove.
	(tui_data_window): Update.
	(tui_free_data_content): Remove.
	(free_content_elements): Remove DATA_WIN case.
---
 gdb/ChangeLog            |  27 +++++++
 gdb/tui/tui-data.c       |  74 +----------------
 gdb/tui/tui-data.h       |   9 +--
 gdb/tui/tui-regs.c       | 166 +++++++++++++++------------------------
 gdb/tui/tui-win.c        |   8 +-
 gdb/tui/tui-windata.c    |  25 +++---
 gdb/tui/tui-wingeneral.c |  12 +--
 7 files changed, 110 insertions(+), 211 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c
index 07bf20e290a..b957043a60f 100644
--- a/gdb/tui/tui-data.c
+++ b/gdb/tui/tui-data.c
@@ -175,8 +175,7 @@  tui_cmd_window::clear_detail ()
 void
 tui_data_window::clear_detail ()
 {
-  regs_content = NULL;
-  regs_content_count = 0;
+  regs_content.clear ();
   regs_column_count = 1;
   display_regs = false;
 }
@@ -360,6 +359,7 @@  init_content_element (struct tui_win_element *element,
   gdb_assert (type != LOCATOR_WIN);
   gdb_assert (type != CMD_WIN);
   gdb_assert (type != DATA_ITEM_WIN);
+  gdb_assert (type != DATA_WIN);
 
   switch (type)
     {
@@ -371,9 +371,6 @@  init_content_element (struct tui_win_element *element,
       element->which_element.source.is_exec_point = FALSE;
       element->which_element.source.has_break = FALSE;
       break;
-    case DATA_WIN:
-      element->which_element.data_window = new tui_data_item_window ();
-      break;
     default:
       break;
     }
@@ -426,39 +423,6 @@  tui_alloc_content (int num_elements, enum tui_win_type type)
 }
 
 
-/* Adds the input number of elements to the windows's content.  If no
-   content has been allocated yet, alloc_content() is called to do
-   this.  The index of the first element added is returned, unless
-   there is a memory allocation error, in which case, (-1) is
-   returned.  */
-int
-tui_add_content_elements (struct tui_gen_win_info *win_info, 
-			  int num_elements)
-{
-  struct tui_win_element *element_ptr;
-  int i, index_start;
-
-  if (win_info->content == NULL)
-    {
-      win_info->content = tui_alloc_content (num_elements, win_info->type);
-      index_start = 0;
-    }
-  else
-    index_start = win_info->content_size;
-  if (win_info->content != NULL)
-    {
-      for (i = index_start; (i < num_elements + index_start); i++)
-	{
-	  element_ptr = XNEW (struct tui_win_element);
-	  win_info->content[i] = element_ptr;
-	  init_content_element (element_ptr, win_info->type);
-	  win_info->content_size++;
-	}
-    }
-
-  return index_start;
-}
-
 tui_gen_win_info::~tui_gen_win_info ()
 {
   if (handle != NULL)
@@ -480,9 +444,6 @@  tui_data_window::~tui_data_window ()
 {
   if (content != NULL)
     {
-      tui_free_data_content (regs_content, regs_content_count);
-      regs_content = NULL;
-      regs_content_count = 0;
       regs_column_count = 1;
       display_regs = false;
       content = NULL;
@@ -515,33 +476,6 @@  tui_free_win_content (struct tui_gen_win_info *win_info)
 }
 
 
-void
-tui_free_data_content (tui_win_content content, 
-		       int content_size)
-{
-  int i;
-
-  /* Remember that data window content elements are of type struct
-     tui_gen_win_info *, each of which whose single element is a data
-     element.  */
-  for (i = 0; i < content_size; i++)
-    {
-      struct tui_gen_win_info *generic_win
-	= content[i]->which_element.data_window;
-
-      if (generic_win != NULL)
-	{
-	  tui_delete_win (generic_win->handle);
-	  generic_win->handle = NULL;
-	  tui_free_win_content (generic_win);
-	}
-    }
-  free_content (content,
-		content_size,
-		DATA_WIN);
-}
-
-
 /**********************************
 ** LOCAL STATIC FUNCTIONS        **
 **********************************/
@@ -596,10 +530,6 @@  free_content_elements (tui_win_content content,
 		    case SRC_WIN:
 		      xfree (element->which_element.source.line);
 		      break;
-		    case DATA_WIN:
-		      delete element->which_element.data_window;
-		      xfree (element);
-		      break;
 		    default:
 		      break;
 		    }
diff --git a/gdb/tui/tui-data.h b/gdb/tui/tui-data.h
index 083b4a5f48e..112fbf4664b 100644
--- a/gdb/tui/tui-data.h
+++ b/gdb/tui/tui-data.h
@@ -204,7 +204,6 @@  typedef char tui_exec_info_content[TUI_EXECINFO_SIZE];
 union tui_which_element
 {
   struct tui_source_element source;	/* The source elements.  */
-  struct tui_data_item_window *data_window;	/* Data display elements.  */
 };
 
 struct tui_win_element
@@ -477,9 +476,8 @@  struct tui_data_window : public tui_win_info
     return DATA_NAME;
   }
 
-  /* Start of regs display content.  */
-  tui_win_content regs_content = NULL;
-  int regs_content_count = 0;
+  /* Windows that are used to display registers.  */
+  std::vector<std::unique_ptr<tui_data_item_window>> regs_content;
   int regs_column_count = 0;
   /* Should regs be displayed at all?  */
   bool display_regs = false;
@@ -554,10 +552,7 @@  extern struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
 /* Data Manipulation Functions.  */
 extern void tui_initialize_static_data (void);
 extern tui_win_content tui_alloc_content (int, enum tui_win_type);
-extern int tui_add_content_elements (struct tui_gen_win_info *, 
-				     int);
 extern void tui_free_win_content (struct tui_gen_win_info *);
-extern void tui_free_data_content (tui_win_content, int);
 extern void tui_free_all_source_wins_content (void);
 extern struct tui_win_info *tui_partial_win_by_name (const char *);
 extern enum tui_layout_type tui_current_layout (void);
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index c3970caa5a6..32e82b23482 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -49,9 +49,9 @@ 
 ******************************************/
 static void tui_display_register (struct tui_data_item_window *data);
 
-static enum tui_status tui_show_register_group (struct reggroup *group,
-						struct frame_info *frame,
-						int refresh_values_only);
+static void tui_show_register_group (struct reggroup *group,
+				     struct frame_info *frame,
+				     int refresh_values_only);
 
 static enum tui_status tui_get_register (struct frame_info *frame,
 					 struct tui_data_item_window *data,
@@ -70,11 +70,11 @@  tui_last_regs_line_no (void)
 {
   int num_lines = (-1);
 
-  if (TUI_DATA_WIN->regs_content_count > 0)
+  if (!TUI_DATA_WIN->regs_content.empty ())
     {
-      num_lines = (TUI_DATA_WIN->regs_content_count
+      num_lines = (TUI_DATA_WIN->regs_content.size ()
 		   / TUI_DATA_WIN->regs_column_count);
-      if (TUI_DATA_WIN->regs_content_count % TUI_DATA_WIN->regs_column_count)
+      if (TUI_DATA_WIN->regs_content.size () % TUI_DATA_WIN->regs_column_count)
 	num_lines++;
     }
   return num_lines;
@@ -87,7 +87,7 @@  tui_last_regs_line_no (void)
 int
 tui_line_from_reg_element_no (int element_no)
 {
-  if (element_no < TUI_DATA_WIN->regs_content_count)
+  if (element_no < TUI_DATA_WIN->regs_content.size ())
     {
       int i, line = (-1);
 
@@ -113,7 +113,7 @@  int
 tui_first_reg_element_no_inline (int line_no)
 {
   if ((line_no * TUI_DATA_WIN->regs_column_count)
-      <= TUI_DATA_WIN->regs_content_count)
+      <= TUI_DATA_WIN->regs_content.size ())
     return (((line_no + 1) * TUI_DATA_WIN->regs_column_count) 
 	    - TUI_DATA_WIN->regs_column_count);
   else
@@ -145,8 +145,9 @@  tui_show_registers (struct reggroup *group)
 
   if (target_has_registers && target_has_stack && target_has_memory)
     {
-      ret = tui_show_register_group (group, get_selected_frame (NULL),
-                                     group == TUI_DATA_WIN->current_group);
+      tui_show_register_group (group, get_selected_frame (NULL),
+			       group == TUI_DATA_WIN->current_group);
+      ret = TUI_SUCCESS;
     }
   if (ret == TUI_FAILURE)
     {
@@ -155,16 +156,11 @@  tui_show_registers (struct reggroup *group)
     }
   else
     {
-      int i;
-
       /* Clear all notation of changed values.  */
-      for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
+      for (auto &&data_item_win : TUI_DATA_WIN->regs_content)
 	{
-	  struct tui_data_item_window *data_item_win;
-
-	  data_item_win = TUI_DATA_WIN->regs_content[i]
-            ->which_element.data_window;
-	  data_item_win->highlight = false;
+	  if (data_item_win != nullptr)
+	    data_item_win->highlight = false;
 	}
       TUI_DATA_WIN->current_group = group;
       tui_display_all_data ();
@@ -176,15 +172,13 @@  tui_show_registers (struct reggroup *group)
    using the given frame.  Values are refreshed only when
    refresh_values_only is TRUE.  */
 
-static enum tui_status
+static void
 tui_show_register_group (struct reggroup *group,
                          struct frame_info *frame, 
 			 int refresh_values_only)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  enum tui_status ret = TUI_FAILURE;
   int nr_regs;
-  int allocated_here = FALSE;
   int regnum, pos;
   char title[80];
 
@@ -213,68 +207,47 @@  tui_show_register_group (struct reggroup *group,
       nr_regs++;
     }
 
-  if (TUI_DATA_WIN->regs_content_count > 0 && !refresh_values_only)
-    {
-      tui_free_data_content (TUI_DATA_WIN->regs_content,
-                             TUI_DATA_WIN->regs_content_count);
-      TUI_DATA_WIN->regs_content_count = 0;
-    }
+  if (!refresh_values_only)
+    TUI_DATA_WIN->regs_content.clear ();
 
-  if (TUI_DATA_WIN->regs_content_count <= 0)
+  if (nr_regs < TUI_DATA_WIN->regs_content.size ())
+    TUI_DATA_WIN->regs_content.resize (nr_regs);
+  else
     {
-      TUI_DATA_WIN->regs_content = tui_alloc_content (nr_regs, DATA_WIN);
-      allocated_here = TRUE;
-      refresh_values_only = FALSE;
+      for (int i = TUI_DATA_WIN->regs_content.size (); i < nr_regs; ++i)
+	TUI_DATA_WIN->regs_content.emplace_back (new tui_data_item_window ());
     }
 
-  if (TUI_DATA_WIN->regs_content != NULL)
+  /* Now set the register names and values.  */
+  pos = 0;
+  for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
     {
-      if (!refresh_values_only || allocated_here)
-	{
-	  TUI_DATA_WIN->content = NULL;
-	  TUI_DATA_WIN->content_size = 0;
-	  tui_add_content_elements (TUI_DATA_WIN, nr_regs);
-	  TUI_DATA_WIN->regs_content = TUI_DATA_WIN->content;
-	  TUI_DATA_WIN->regs_content_count = nr_regs;
-	}
+      struct tui_data_item_window *data_item_win;
+      const char *name;
 
-      /* Now set the register names and values.  */
-      pos = 0;
-      for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); regnum++)
-        {
-	  struct tui_data_item_window *data_item_win;
-          const char *name;
-
-          /* Must be in the group.  */
-          if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
-            continue;
-
-	  /* If the register name is empty, it is undefined for this
-	     processor, so don't display anything.  */
-	  name = gdbarch_register_name (gdbarch, regnum);
-	  if (name == 0 || *name == '\0')
-	    continue;
-
-	  data_item_win =
-            TUI_DATA_WIN->regs_content[pos]->which_element.data_window;
-          if (data_item_win)
-            {
-              if (!refresh_values_only)
-                {
-                  data_item_win->item_no = regnum;
-                  data_item_win->name = name;
-                  data_item_win->highlight = false;
-                }
-              tui_get_register (frame, data_item_win, regnum, 0);
-            }
-          pos++;
-	}
+      /* Must be in the group.  */
+      if (!gdbarch_register_reggroup_p (gdbarch, regnum, group))
+	continue;
 
-      TUI_DATA_WIN->content_size = TUI_DATA_WIN->regs_content_count;
-      ret = TUI_SUCCESS;
-    }
+      /* If the register name is empty, it is undefined for this
+	 processor, so don't display anything.  */
+      name = gdbarch_register_name (gdbarch, regnum);
+      if (name == 0 || *name == '\0')
+	continue;
 
-  return ret;
+      data_item_win = TUI_DATA_WIN->regs_content[pos].get ();
+      if (data_item_win)
+	{
+	  if (!refresh_values_only)
+	    {
+	      data_item_win->item_no = regnum;
+	      data_item_win->name = name;
+	      data_item_win->highlight = false;
+	    }
+	  tui_get_register (frame, data_item_win, regnum, 0);
+	}
+      pos++;
+    }
 }
 
 /* Function to display the registers in the content from
@@ -284,21 +257,16 @@  tui_show_register_group (struct reggroup *group,
 void
 tui_display_registers_from (int start_element_no)
 {
-  if (TUI_DATA_WIN->regs_content != NULL
-      && TUI_DATA_WIN->regs_content_count > 0)
+  if (!TUI_DATA_WIN->regs_content.empty ())
     {
-      int i = start_element_no;
       int j, item_win_width, cur_y;
 
       int max_len = 0;
-      for (i = 0; i < TUI_DATA_WIN->regs_content_count; i++)
+      for (auto &&data_item_win : TUI_DATA_WIN->regs_content)
         {
-          struct tui_data_item_window *data_item_win;
           char *p;
           int len;
 
-          data_item_win
-	    = TUI_DATA_WIN->regs_content[i]->which_element.data_window;
           len = 0;
           p = data_item_win->content;
           if (p != 0)
@@ -314,7 +282,7 @@  tui_display_registers_from (int start_element_no)
             max_len = len;
         }
       item_win_width = max_len + 1;
-      i = start_element_no;
+      int i = start_element_no;
 
       TUI_DATA_WIN->regs_column_count =
         (TUI_DATA_WIN->width - 2) / item_win_width;
@@ -326,19 +294,18 @@  tui_display_registers_from (int start_element_no)
       /* Now create each data "sub" window, and write the display into
 	 it.  */
       cur_y = 1;
-      while (i < TUI_DATA_WIN->regs_content_count 
+      while (i < TUI_DATA_WIN->regs_content.size ()
 	     && cur_y <= TUI_DATA_WIN->viewport_height)
 	{
 	  for (j = 0;
 	       j < TUI_DATA_WIN->regs_column_count
-		 && i < TUI_DATA_WIN->regs_content_count;
+		 && i < TUI_DATA_WIN->regs_content.size ();
 	       j++)
 	    {
 	      struct tui_data_item_window *data_item_win;
 
 	      /* Create the window if necessary.  */
-	      data_item_win = TUI_DATA_WIN->regs_content[i]
-                ->which_element.data_window;
+	      data_item_win = TUI_DATA_WIN->regs_content[i].get ();
               if (data_item_win->handle != NULL
                   && (data_item_win->height != 1
                       || data_item_win->width != item_win_width
@@ -379,8 +346,7 @@  static void
 tui_display_reg_element_at_line (int start_element_no,
 				 int start_line_no)
 {
-  if (TUI_DATA_WIN->regs_content != NULL
-      && TUI_DATA_WIN->regs_content_count > 0)
+  if (!TUI_DATA_WIN->regs_content.empty ())
     {
       int element_no = start_element_no;
 
@@ -414,7 +380,7 @@  int
 tui_display_registers_from_line (int line_no, 
 				 int force_display)
 {
-  if (TUI_DATA_WIN->regs_content_count > 0)
+  if (!TUI_DATA_WIN->regs_content.empty ())
     {
       int line, element_no;
 
@@ -427,7 +393,7 @@  tui_display_registers_from_line (int line_no,
 	  if (line_no >= tui_last_regs_line_no ())
 	    {
 	      if ((line = tui_line_from_reg_element_no (
-		 TUI_DATA_WIN->regs_content_count - 1)) < 0)
+		 TUI_DATA_WIN->regs_content.size () - 1)) < 0)
 		line = 0;
 	    }
 	  else
@@ -437,8 +403,7 @@  tui_display_registers_from_line (int line_no,
 	line = line_no;
 
       element_no = tui_first_reg_element_no_inline (line);
-      if (element_no
-	  < TUI_DATA_WIN->regs_content_count)
+      if (element_no < TUI_DATA_WIN->regs_content.size ())
 	tui_display_reg_element_at_line (element_no, line);
       else
 	line = (-1);
@@ -459,30 +424,23 @@  tui_check_register_values (struct frame_info *frame)
   if (TUI_DATA_WIN != NULL
       && TUI_DATA_WIN->is_visible)
     {
-      if (TUI_DATA_WIN->regs_content_count <= 0 
+      if (TUI_DATA_WIN->regs_content.empty ()
 	  && TUI_DATA_WIN->display_regs)
 	tui_show_registers (TUI_DATA_WIN->current_group);
       else
 	{
-	  int i;
-
-	  for (i = 0; (i < TUI_DATA_WIN->regs_content_count); i++)
+	  for (auto &&data_item_win_ptr : TUI_DATA_WIN->regs_content)
 	    {
-	      struct tui_data_item_window *data_item_win_ptr;
 	      int was_hilighted;
 
-	      data_item_win_ptr = TUI_DATA_WIN->regs_content[i]->
-                which_element.data_window;
 	      was_hilighted = data_item_win_ptr->highlight;
 
-              tui_get_register (frame, data_item_win_ptr,
+              tui_get_register (frame, data_item_win_ptr.get (),
                                 data_item_win_ptr->item_no,
 				&data_item_win_ptr->highlight);
 
 	      if (data_item_win_ptr->highlight || was_hilighted)
-		{
-                  tui_display_register (data_item_win_ptr);
-		}
+		tui_display_register (data_item_win_ptr.get ());
 	    }
 	}
     }
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 64da13c3bb5..468e245351c 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -1267,12 +1267,10 @@  void
 tui_data_window::set_new_height (int height)
 {
   /* Delete all data item windows.  */
-  for (int i = 0; i < content_size; i++)
+  for (auto &&win : regs_content)
     {
-      struct tui_gen_win_info *gen_win_info
-	= content[i]->which_element.data_window;
-      tui_delete_win (gen_win_info->handle);
-      gen_win_info->handle = NULL;
+      tui_delete_win (win->handle);
+      win->handle = NULL;
     }
 }
 
diff --git a/gdb/tui/tui-windata.c b/gdb/tui/tui-windata.c
index 23510f6da84..7ff50a0c905 100644
--- a/gdb/tui/tui-windata.c
+++ b/gdb/tui/tui-windata.c
@@ -44,11 +44,11 @@ 
 int
 tui_data_window::first_data_item_displayed ()
 {
-  for (int i = 0; i < content_size; i++)
+  for (int i = 0; i < regs_content.size (); i++)
     {
       struct tui_gen_win_info *data_item_win;
 
-      data_item_win = content[i]->which_element.data_window;
+      data_item_win = regs_content[i].get ();
       if (data_item_win->handle != NULL && data_item_win->is_visible)
 	return i;
     }
@@ -62,16 +62,11 @@  tui_data_window::first_data_item_displayed ()
 void
 tui_delete_data_content_windows (void)
 {
-  int i;
-  struct tui_gen_win_info *data_item_win_ptr;
-
-  for (i = 0; (i < TUI_DATA_WIN->content_size); i++)
+  for (auto &&win : TUI_DATA_WIN->regs_content)
     {
-      data_item_win_ptr
-	= TUI_DATA_WIN->content[i]->which_element.data_window;
-      tui_delete_win (data_item_win_ptr->handle);
-      data_item_win_ptr->handle = NULL;
-      data_item_win_ptr->is_visible = false;
+      tui_delete_win (win->handle);
+      win->handle = NULL;
+      win->is_visible = false;
     }
 }
 
@@ -104,7 +99,7 @@  tui_erase_data_content (const char *prompt)
 void
 tui_display_all_data (void)
 {
-  if (TUI_DATA_WIN->content_size <= 0)
+  if (TUI_DATA_WIN->regs_content.empty ())
     tui_erase_data_content (NO_DATA_STRING);
   else
     {
@@ -138,7 +133,7 @@  tui_display_data_from (int element_no, int reuse_windows)
 {
   int first_line = (-1);
 
-  if (element_no < TUI_DATA_WIN->regs_content_count)
+  if (element_no < TUI_DATA_WIN->regs_content.size ())
     first_line = tui_line_from_reg_element_no (element_no);
   else
     { /* Calculate the first_line from the element number.  */
@@ -159,7 +154,7 @@  void
 tui_data_window::refresh_all ()
 {
   tui_erase_data_content (NULL);
-  if (content_size > 0)
+  if (!regs_content.empty ())
     {
       int first_element = first_data_item_displayed ();
 
@@ -177,7 +172,7 @@  tui_data_window::do_scroll_vertical (int num_to_scroll)
   int first_line = (-1);
 
   first_element_no = first_data_item_displayed ();
-  if (first_element_no < regs_content_count)
+  if (first_element_no < regs_content.size ())
     first_line = tui_line_from_reg_element_no (first_element_no);
   else
     { /* Calculate the first line from the element number which is in
diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c
index 9bc4e2b24ca..8f64e73e284 100644
--- a/gdb/tui/tui-wingeneral.c
+++ b/gdb/tui/tui-wingeneral.c
@@ -45,16 +45,12 @@  tui_gen_win_info::refresh_window ()
 void
 tui_data_window::refresh_window ()
 {
-  if (content_size > 0)
+  if (!regs_content.empty ())
     {
-      for (int i = 0; i < content_size; i++)
+      for (auto &&win : regs_content)
 	{
-	  struct tui_gen_win_info *data_item_win_ptr;
-
-	  data_item_win_ptr = content[i]->which_element.data_window;
-	  if (data_item_win_ptr != NULL
-	      && data_item_win_ptr->handle != NULL)
-	    wrefresh (data_item_win_ptr->handle);
+	  if (win != NULL && win->handle != NULL)
+	    wrefresh (win->handle);
 	}
     }
   else