handle NULL screen from screen_for_xwindow

2002-07-23  Havoc Pennington  <hp@redhat.com>

	* 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
This commit is contained in:
Havoc Pennington 2002-07-23 19:12:02 +00:00 committed by Havoc Pennington
parent dc73aaeb39
commit 197c81178c
6 changed files with 59 additions and 1 deletions

View File

@ -1,3 +1,15 @@
2002-07-23 Havoc Pennington <hp@redhat.com>
* 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 <jacob@ximian.com>
* src/update-from-egg.sh: steal from profterm to fix build

View File

@ -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

View File

@ -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);

View File

@ -640,7 +640,10 @@ 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);
}

View File

@ -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);

View File

@ -29,6 +29,37 @@
#include <errno.h>
#include <string.h>
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
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 ();
}