From: Dmitry Antipov Date: Wed, 25 Jul 2012 05:09:02 +0000 (+0400) Subject: Adjust buffer text indirection counters at the end of Fkill_buffer. X-Git-Tag: emacs-24.2.90~1087 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=04e9897cf70e46c703b1412d022511e80314a720;p=emacs.git Adjust buffer text indirection counters at the end of Fkill_buffer. * buffer.c (Fkill_buffer): Adjust indirection counters when the buffer is definitely dead. This should really fix an issue reported by Christoph Scholtes again. (Bug#12007). (init_buffer_once): Initialize indirection counters of buffer_defaults and buffer_local_symbols (for sanity and safety). --- diff --git a/src/ChangeLog b/src/ChangeLog index a7ed81da2d2..2c82af88f93 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2012-07-25 Dmitry Antipov + + Adjust buffer text indirection counters at the end of Fkill_buffer. + * buffer.c (Fkill_buffer): Adjust indirection counters when the + buffer is definitely dead. This should really fix an issue reported + by Christoph Scholtes again. (Bug#12007). + (init_buffer_once): Initialize indirection counters of + buffer_defaults and buffer_local_symbols (for sanity and safety). + 2012-07-24 Eli Zaretskii * xdisp.c (init_iterator): Don't compute dimensions of truncation @@ -7,7 +16,7 @@ 2012-07-24 Dmitry Antipov Simplify copy_overlay. - * buffer.c (copy_overlay): Simplify, use build_marker. + * buffer.c (copy_overlay): Simplify. Use build_marker. * lisp.h (struct Lisp_Overlay): Restore comment with minor tweaks. 2012-07-23 Eli Zaretskii diff --git a/src/buffer.c b/src/buffer.c index c017db7b034..06d385110c6 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1560,14 +1560,6 @@ cleaning up all windows currently displaying the buffer to be killed. */) if (EQ (buffer, XWINDOW (minibuf_window)->buffer)) return Qnil; - /* Notify our base buffer that we don't share the text anymore. */ - if (b->base_buffer) - { - eassert (b->indirections == -1); - b->base_buffer->indirections--; - eassert (b->base_buffer->indirections >= 0); - } - /* When we kill an ordinary buffer which shares it's buffer text with indirect buffer(s), we must kill indirect buffer(s) too. We do it at this stage so nothing terrible happens if they @@ -1708,7 +1700,15 @@ cleaning up all windows currently displaying the buffer to be killed. */) BVAR (b, name) = Qnil; BLOCK_INPUT; - if (! b->base_buffer) + if (b->base_buffer) + { + /* Notify our base buffer that we don't share the text anymore. */ + eassert (b->indirections == -1); + b->base_buffer->indirections--; + eassert (b->base_buffer->indirections >= 0); + } + else + /* No one shares our buffer text, can free it. */ free_buffer_text (b); if (b->newline_cache) @@ -4897,6 +4897,9 @@ init_buffer_once (void) /* Prevent GC from getting confused. */ buffer_defaults.text = &buffer_defaults.own_text; buffer_local_symbols.text = &buffer_local_symbols.own_text; + /* No one will share the text with these buffers, but let's play it safe. */ + buffer_defaults.indirections = 0; + buffer_local_symbols.indirections = 0; BUF_INTERVALS (&buffer_defaults) = 0; BUF_INTERVALS (&buffer_local_symbols) = 0; XSETPVECTYPESIZE (&buffer_defaults, PVEC_BUFFER, pvecsize);