From 35ed265eb9d610270a4a6ff8c4c99af5acacd8e3 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Thu, 21 Apr 2005 17:53:39 +0000 Subject: [PATCH] r3888: Try to cope with BadWindow errors (suggested by Kacper Wysock). --- ROX-Filer/Help/Changes | 4 ++++ ROX-Filer/src/main.c | 62 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 72a60d26..0560b43e 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -2,6 +2,10 @@ A RISC OS-like filer for X by Thomas Leonard +21-Apr-2005 +~~~~~~~~~~~ +Try to cope with BadWindow errors (suggested by Kacper Wysock). + 17-Apr-2005 ~~~~~~~~~~~ Bugfix: Replacing an existing display settings would erase all the other diff --git a/ROX-Filer/src/main.c b/ROX-Filer/src/main.c index f0ea95f8..0218e987 100644 --- a/ROX-Filer/src/main.c +++ b/ROX-Filer/src/main.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #ifdef HAVE_GETOPT_LONG @@ -192,27 +193,46 @@ static void xrandr_size_change(GdkScreen *screen, gpointer user_data); static int rox_x_error(Display *display, XErrorEvent *error) { - gchar buf[64]; - - XGetErrorText(display, error->error_code, buf, 63); - - g_warning ("The program '%s' received an X Window System error.\n" - "This probably reflects a bug in the program.\n" - "The error was '%s'.\n" - " (Details: serial %ld error_code %d request_code %d minor_code %d)\n" - " (Note to programmers: normally, X errors are reported asynchronously;\n" - " that is, you will receive the error a while after causing it.\n" - " To debug your program, run it with the --sync command line\n" - " option to change this behavior. You can then get a meaningful\n" - " backtrace from your debugger.)", - g_get_prgname (), - buf, - error->serial, - error->error_code, - error->request_code, - error->minor_code); - - abort(); + gchar buf[64]; + + XGetErrorText(display, error->error_code, buf, 63); + + g_warning ("The program '%s' received an X Window System error.\n" + "This probably reflects a bug in the program.\n" + "The error was '%s'.\n" + " (Details: serial %ld error_code %d request_code %d minor_code %d)\n" + " (Note to programmers: normally, X errors are reported asynchronously;\n" + " that is, you will receive the error a while after causing it.\n" + " To debug your program, run it with the --sync command line\n" + " option to change this behavior. You can then get a meaningful\n" + " backtrace from your debugger.)", + g_get_prgname (), + buf, + error->serial, + error->error_code, + error->request_code, + error->minor_code); + + /* Try to cope with BadWindow errors */ + if (error->error_code == 3) + { + static time_t last_error = 0; + time_t now; + now = time(NULL); + + if (last_error + 5 > now) + abort(); /* Errors coming too fast... */ + + last_error = now; + + delayed_error(_("We got a BadWindow error from the X server. " + "This might be due to this GTK bug (during drag-and-drop?):\n" + "http://bugzilla.gnome.org/show_bug.cgi?id=152151\n" + "Trying to continue...")); + return 0; + } + + abort(); } /* Parses the command-line to work out what the user wants to do. -- 2.11.4.GIT