From 436bc8e0a73e02ed0840633c4d4d4922a222db24 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Mon, 23 Jul 2012 19:57:20 +0300 Subject: [PATCH] Fix bug #12025 with a crash when displaying tooltips. src/print.c (print_object): Don't crash when a frame's name is nil or invalid. src/window.c (decode_any_window): Disable CHECK_LIVE_FRAME test, as it signals an error when a tooltip frame is being created. --- src/ChangeLog | 8 ++++++++ src/print.c | 13 ++++++++++++- src/window.c | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index fb25d8dc937..40654e5a492 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2012-07-23 Eli Zaretskii + + * print.c (print_object): Don't crash when a frame's name is nil + or invalid. (Bug#12025) + + * window.c (decode_any_window): Disable CHECK_LIVE_FRAME test, as + it signals an error when a tooltip frame is being created. + 2012-07-23 Dmitry Antipov Cleanup miscellaneous objects allocation and initialization. diff --git a/src/print.c b/src/print.c index b650b1265b1..fc435efe7c5 100644 --- a/src/print.c +++ b/src/print.c @@ -1897,10 +1897,21 @@ print_object (Lisp_Object obj, register Lisp_Object printcharfun, int escapeflag else if (FRAMEP (obj)) { int len; + Lisp_Object frame_name = XFRAME (obj)->name; + strout ((FRAME_LIVE_P (XFRAME (obj)) ? "#name, printcharfun); + if (!STRINGP (frame_name)) + { + /* A frame could be too young and have no name yet; + don't crash. */ + if (SYMBOLP (frame_name)) + frame_name = Fsymbol_name (frame_name); + else /* can't happen: name should be either nil or string */ + frame_name = build_string ("*INVALID*FRAME*NAME*"); + } + print_string (frame_name, printcharfun); len = sprintf (buf, " %p", XFRAME (obj)); strout (buf, len, len, printcharfun); PRINTCHAR ('>'); diff --git a/src/window.c b/src/window.c index b7b6e283cc1..e80462ae945 100644 --- a/src/window.c +++ b/src/window.c @@ -151,7 +151,8 @@ decode_any_window (register Lisp_Object window) CHECK_WINDOW (window); w = XWINDOW (window); - CHECK_LIVE_FRAME (w->frame); + /* The following test throws up every time a tooltip frame is displayed. */ + /* CHECK_LIVE_FRAME (w->frame); */ return w; } -- 2.39.2