--- src/vte.c.orig	2004-08-30 15:14:26.671426014 +0900
+++ src/vte.c	2004-08-30 15:15:55.299253021 +0900
@@ -11095,12 +11095,6 @@
 	g_return_if_fail(VTE_IS_TERMINAL(widget));
 	terminal = VTE_TERMINAL(widget);
 
-	/* Clean up our draw structure. */
-	if (terminal->pvt->draw != NULL) {
-		_vte_draw_free(terminal->pvt->draw);
-	}
-	terminal->pvt->draw = NULL;
-
 	/* Disconnect from background-change events. */
 	g_signal_handlers_disconnect_by_func(G_OBJECT(vte_bg_get()),
 					     root_pixmap_changed_cb,
@@ -11149,6 +11143,12 @@
 	}
 	terminal->pvt->im_preedit_cursor = 0;
 
+	/* Clean up our draw structure. */
+	if (terminal->pvt->draw != NULL) {
+		_vte_draw_free(terminal->pvt->draw);
+	}
+	terminal->pvt->draw = NULL;
+
 	/* Unmap the widget if it hasn't been already. */
 	if (GTK_WIDGET_MAPPED(widget)) {
 		gtk_widget_unmap(widget);
