]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #17281 with infloop in line-pixel-height.
authorEli Zaretskii <eliz@gnu.org>
Thu, 17 Apr 2014 08:58:59 +0000 (11:58 +0300)
committerEli Zaretskii <eliz@gnu.org>
Thu, 17 Apr 2014 08:58:59 +0000 (11:58 +0300)
 src/xdisp.c (Fline_pixel_height): Don't assume that the current
 buffer and the selected window's buffer are one and the same.

src/ChangeLog
src/xdisp.c

index d0aa2e59e0197583162381776b23b6fc57b1798c..122b093f2a0cd0742daf59bdfc37394a75f5db96 100644 (file)
@@ -1,5 +1,9 @@
 2014-04-17  Eli Zaretskii  <eliz@gnu.org>
 
+       * xdisp.c (Fline_pixel_height): Don't assume that the current
+       buffer and the selected window's buffer are one and the same.
+       (Bug#17281)
+
        * insdel.c (invalidate_buffer_caches): Invalidate the bidi
        paragraph-start cache before the newline cache.  (Bug#17269)
 
index eb3a6df1fc5afce394ebf13b89aba92e3da0f06c..ad5f6a6bf83c8c418f6e690b04de1c81b2bcd3b7 100644 (file)
@@ -1262,12 +1262,23 @@ Value is the height in pixels of the line at point.  */)
   struct it it;
   struct text_pos pt;
   struct window *w = XWINDOW (selected_window);
+  struct buffer *old_buffer = NULL;
+  Lisp_Object result;
 
+  if (XBUFFER (w->contents) != current_buffer)
+    {
+      old_buffer = current_buffer;
+      set_buffer_internal_1 (XBUFFER (w->contents));
+    }
   SET_TEXT_POS (pt, PT, PT_BYTE);
   start_display (&it, w, pt);
   it.vpos = it.current_y = 0;
   last_height = 0;
-  return make_number (line_bottom_y (&it));
+  result = make_number (line_bottom_y (&it));
+  if (old_buffer)
+    set_buffer_internal_1 (old_buffer);
+
+  return result;
 }
 
 /* Return the default pixel height of text lines in window W.  The