--- gnome-panel-2.14.2/gnome-panel/panel-applet-frame.c.xio-error	2006-03-06 15:19:20.000000000 -0500
+++ gnome-panel-2.14.2/gnome-panel/panel-applet-frame.c	2006-07-26 11:01:06.000000000 -0400
@@ -31,6 +31,8 @@
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
 
+#include <X11/Xlib.h>
+
 #include "panel-applet-frame.h"
 #include "panel-profile.h"
 #include "panel-util.h"
@@ -105,6 +107,10 @@ static void panel_applet_frame_activated
 					  CORBA_Environment *ev,
 					  gpointer          *data);
 
+static int (* panel_applet_frame_old_xio_error_handler) (Display *);
+static int panel_applet_frame_xio_error_handler (Display *display);
+static gboolean panel_applet_frame_display_is_dead = FALSE;
+
 void
 panel_applet_frame_sync_menu_state (PanelAppletFrame *frame)
 {
@@ -943,6 +949,9 @@ panel_applet_frame_cnx_broken (ORBitConn
 
 	g_return_if_fail (PANEL_IS_APPLET_FRAME (frame));
 
+	if (panel_applet_frame_display_is_dead)
+		return;
+
 	screen = gtk_widget_get_screen (GTK_WIDGET (frame));
 
 	if (frame->priv->iid)
@@ -1236,6 +1245,17 @@ panel_applet_frame_event_listener (Bonob
 		panel_applet_frame_set_size_hints_from_any (frame, any);
 }
 
+static int
+panel_applet_frame_xio_error_handler (Display *display)
+{
+    panel_applet_frame_display_is_dead = TRUE;
+
+    if (panel_applet_frame_old_xio_error_handler)
+	    return panel_applet_frame_old_xio_error_handler (display);
+
+    return 0;
+}
+
 static void
 panel_applet_frame_activated (Bonobo_Unknown     object,
 			      CORBA_Environment *ev,
@@ -1373,6 +1393,8 @@ panel_applet_frame_activated (Bonobo_Unk
 	ORBit_small_listen_for_broken (object,
 				       G_CALLBACK (panel_applet_frame_cnx_broken),
 				       frame);
+	panel_applet_frame_old_xio_error_handler = 
+           XSetIOErrorHandler (panel_applet_frame_xio_error_handler);
 
 	gtk_container_add (GTK_CONTAINER (frame), widget);
 
