From 164df7bf8518526c51e063d333a364934096652b Mon Sep 17 00:00:00 2001 From: Tomeu Date: Tue, 3 Apr 2007 20:17:30 +0200 Subject: [PATCH 1/2] Add XSetErrorHandler for not crashing on X errors caused by Gecko plugins. --- lib/src/sugar-browser.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/src/sugar-browser.cpp b/lib/src/sugar-browser.cpp index b8b69dc3..ac0c4196 100644 --- a/lib/src/sugar-browser.cpp +++ b/lib/src/sugar-browser.cpp @@ -24,6 +24,7 @@ #include "GeckoContentHandler.h" #include "GeckoDownload.h" +#include #include #include #include @@ -89,6 +90,34 @@ static const nsModuleComponentInfo sSugarComponents[] = { } }; +int (*old_handler) (Display *, XErrorEvent *); + +static int +error_handler (Display *d, XErrorEvent *e) +{ + gchar buf[64]; + gchar *msg; + + XGetErrorText (d, e->error_code, buf, 63); + + msg = + g_strdup_printf ("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", + g_get_prgname (), + buf, + e->serial, + e->error_code, + e->request_code, + e->minor_code); + + g_error ("%s", msg); + + return 0; + /*return (*old_handler)(d, e);*/ +} + static void setup_plugin_path () { @@ -113,6 +142,8 @@ sugar_browser_startup(const char *profile_path, const char *profile_name) gtk_moz_embed_set_profile_path(profile_path, profile_name); + old_handler = XSetErrorHandler (error_handler); + gtk_moz_embed_push_startup(); nsCOMPtr prefService; From 29d518eb553c3a8df64d42272b50054b8f9d8eb1 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 4 Apr 2007 14:11:38 +0200 Subject: [PATCH 2/2] Do not abort on X errors --- lib/src/sugar-browser.cpp | 26 +++++++++++++------------- tools/build-snapshot.sh | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/src/sugar-browser.cpp b/lib/src/sugar-browser.cpp index ac0c4196..cd455b6f 100644 --- a/lib/src/sugar-browser.cpp +++ b/lib/src/sugar-browser.cpp @@ -98,21 +98,21 @@ error_handler (Display *d, XErrorEvent *e) gchar buf[64]; gchar *msg; - XGetErrorText (d, e->error_code, buf, 63); + XGetErrorText(d, e->error_code, buf, 63); msg = - g_strdup_printf ("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", - g_get_prgname (), - buf, - e->serial, - e->error_code, - e->request_code, - e->minor_code); + g_strdup_printf("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", + g_get_prgname (), + buf, + e->serial, + e->error_code, + e->request_code, + e->minor_code); - g_error ("%s", msg); + g_warning ("%s", msg); return 0; /*return (*old_handler)(d, e);*/ @@ -142,7 +142,7 @@ sugar_browser_startup(const char *profile_path, const char *profile_name) gtk_moz_embed_set_profile_path(profile_path, profile_name); - old_handler = XSetErrorHandler (error_handler); + old_handler = XSetErrorHandler(error_handler); gtk_moz_embed_push_startup(); diff --git a/tools/build-snapshot.sh b/tools/build-snapshot.sh index eaba1a5d..7d3bd112 100755 --- a/tools/build-snapshot.sh +++ b/tools/build-snapshot.sh @@ -1,6 +1,6 @@ VERSION=0.63 DATE=`date +%Y%m%d` -RELEASE=2.69 +RELEASE=2.72 TARBALL=sugar-$VERSION-$RELEASE.${DATE}git.tar.bz2 rm sugar-$VERSION.tar.bz2