From 6c4e879b07fd5953414068d50e03eb75531122e5 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Mon, 2 Aug 2010 21:57:54 +0000
Subject: [PATCH] fix for when making the grid smaller than previous

---
 src/sview/grid.c   |  2 +-
 src/sview/popups.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/sview/grid.c b/src/sview/grid.c
index ef344df5ea0..37722f8ede2 100644
--- a/src/sview/grid.c
+++ b/src/sview/grid.c
@@ -984,7 +984,7 @@ extern int update_grid_table(GtkTable *table, List button_list, List node_list)
 	}
 
 	if(!node_list) {
-		g_print("setup_grid_table: no node_list given\n");
+		g_print("update_grid_table: no node_list given\n");
 		return SLURM_ERROR;
 	}
 
diff --git a/src/sview/popups.c b/src/sview/popups.c
index 40a2347a05c..5dfea786350 100644
--- a/src/sview/popups.c
+++ b/src/sview/popups.c
@@ -821,13 +821,27 @@ extern void change_grid_popup(GtkAction *action, gpointer user_data)
 		   && (vert == working_sview_config.grid_vert)) {
 			temp = g_strdup_printf("Grid: Nothing changed.");
 		} else {
+			bool refresh = 0;
 			temp = g_strdup_printf(
 				"Grid set to %d nodes breaks "
 				"at %d H and %d V.",
 				working_sview_config.grid_x_width,
 				working_sview_config.grid_hori,
 				working_sview_config.grid_vert);
+			/* If the old width was wider than the
+			 * current we need to remake the list so the
+			 * table gets set up correctly, so destroy it
+			 * here and it will be remade in get_system_stats(). */
+			if((width > working_sview_config.grid_x_width)
+			   && grid_button_list) {
+				list_destroy(grid_button_list);
+				grid_button_list = NULL;
+				refresh = 1;
+			}
 			get_system_stats(main_grid_table);
+			if(refresh)
+				refresh_main(NULL, NULL);
+
 		}
 		gtk_statusbar_pop(GTK_STATUSBAR(main_statusbar),
 				  STATUS_REFRESH);
-- 
GitLab