Index: gedit/gedit-window-private.h
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-window-private.h,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 gedit-window-private.h
--- gedit/gedit-window-private.h	7 Aug 2006 16:42:40 -0000	1.4
+++ gedit/gedit-window-private.h	7 Oct 2006 09:35:20 -0000
@@ -82,13 +82,14 @@ struct _GeditWindowPrivate
 	gint		side_panel_size;
 	gint		bottom_panel_size;
 
-	gboolean	removing_tabs;
-	
 	GeditWindowState state;
 
 	GtkWindowGroup *window_group;
 	
 	gchar          *default_path;
+
+	gboolean	removing_tabs : 1;
+	gboolean	destroy_has_run : 1;
 };
 
 G_END_DECLS
Index: gedit/gedit-window.c
===================================================================
RCS file: /cvs/gnome/gedit/gedit/gedit-window.c,v
retrieving revision 1.39
diff -u -p -u -p -r1.39 gedit-window.c
--- gedit/gedit-window.c	23 Sep 2006 14:37:09 -0000	1.39
+++ gedit/gedit-window.c	7 Oct 2006 09:35:21 -0000
@@ -168,13 +168,10 @@ gedit_window_finalize (GObject *object)
 }
 
 static void
-gedit_window_destroy (GtkObject *object)
+save_panes_state (GeditWindow *window)
 {
-	GeditWindow *window;
 	gint pane_page;
 
-	window = GEDIT_WINDOW (object);
-
 	if (gedit_prefs_manager_window_size_can_set ())
 		gedit_prefs_manager_set_window_size (window->priv->width,
 						     window->priv->height);
@@ -201,6 +198,21 @@ gedit_window_destroy (GtkObject *object)
 	if (pane_page != 0 &&
 	    gedit_prefs_manager_bottom_panel_active_page_can_set ())
 		gedit_prefs_manager_set_bottom_panel_active_page (pane_page);
+}
+
+static void
+gedit_window_destroy (GtkObject *object)
+{
+	GeditWindow *window;
+	gint pane_page;
+
+	window = GEDIT_WINDOW (object);
+
+	if (!window->priv->destroy_has_run)
+	{
+		save_panes_state (window);
+		window->priv->destroy_has_run = TRUE;
+	}
 
 	GTK_OBJECT_CLASS (gedit_window_parent_class)->destroy (object);
 }
@@ -3057,6 +3069,7 @@ gedit_window_init (GeditWindow *window)
 	window->priv->num_tabs = 0;
 	window->priv->removing_tabs = FALSE;
 	window->priv->state = GEDIT_WINDOW_STATE_NORMAL;
+	window->priv->destroy_has_run = FALSE;
 
 	window->priv->window_group = gtk_window_group_new ();
 	gtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window));
