diff --git a/ChangeLog b/ChangeLog index 02ae37b46..ebb1ba77a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2002-07-23 Havoc Pennington + + * src/keybindings.c (meta_display_process_key_event): handle + NULL screen from screen_for_xwindow + + * src/display.c (meta_display_screen_for_xwindow): put an error + trap around the XGetWindowAttributes(), should fix the popular + "closing a window results in a crash" bug. + + * src/util.c (print_backtrace): support optional backtrace + feature using gnu libc backtrace() call + 2002-07-15 jacob berkman * src/update-from-egg.sh: steal from profterm to fix build diff --git a/configure.in b/configure.in index dda2e27a9..c38085cd8 100644 --- a/configure.in +++ b/configure.in @@ -82,6 +82,11 @@ if test "x$GCC" = "xyes"; then fi changequote([,])dnl + +## try definining HAVE_BACKTRACE +AC_CHECK_HEADERS(execinfo.h, [AC_CHECK_FUNCS(backtrace)]) + + ALL_LINGUAS="az ca da de es fr gl it ja ko lv ms no pl pt ru sk sv tr uk zh_TW" AM_GLIB_GNU_GETTEXT diff --git a/src/core.c b/src/core.c index eef5d8e6d..4c86aec84 100644 --- a/src/core.c +++ b/src/core.c @@ -525,6 +525,8 @@ meta_core_begin_grab_op (Display *xdisplay, screen = meta_display_screen_for_xwindow (display, frame_xwindow); window = meta_display_lookup_x_window (display, frame_xwindow); + g_assert (screen != NULL); + if (window == NULL || window->frame == NULL) meta_bug ("No such frame window 0x%lx!\n", frame_xwindow); diff --git a/src/display.c b/src/display.c index 51c0ac2c8..74d124254 100644 --- a/src/display.c +++ b/src/display.c @@ -640,8 +640,11 @@ meta_display_screen_for_xwindow (MetaDisplay *display, { XWindowAttributes attr; + meta_error_trap_push (display); XGetWindowAttributes (display->xdisplay, xwindow, &attr); - + if (meta_error_trap_pop (display) != Success) + return NULL; + return meta_display_screen_for_x_screen (display, attr.screen); } diff --git a/src/keybindings.c b/src/keybindings.c index 9cd069cba..ad50103e3 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -1273,6 +1273,9 @@ meta_display_process_key_event (MetaDisplay *display, screen = meta_display_screen_for_xwindow (display, event->xany.window); + if (screen == NULL) + return; /* event window is destroyed */ + /* window may be NULL */ keysym = XKeycodeToKeysym (display->xdisplay, event->xkey.keycode, 0); diff --git a/src/util.c b/src/util.c index 3c5c98550..aff236e9e 100644 --- a/src/util.c +++ b/src/util.c @@ -29,6 +29,37 @@ #include #include +#ifdef HAVE_BACKTRACE +#include +static void +print_backtrace (void) +{ + void *bt[500]; + int bt_size; + int i; + char **syms; + + bt_size = backtrace (bt, 500); + + syms = backtrace_symbols (bt, bt_size); + + i = 0; + while (i < bt_size) + { + meta_verbose (" %s\n", syms[i]); + ++i; + } + + free (syms); +} +#else +static void +print_backtrace (void) +{ + meta_verbose ("Not compiled with backtrace support\n"); +} +#endif + static gboolean is_verbose = FALSE; static gboolean is_debugging = FALSE; static gboolean replace_current = FALSE; @@ -264,6 +295,8 @@ meta_bug (const char *format, ...) g_free (str); + print_backtrace (); + /* stop us in a debugger */ abort (); }