emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Killing a frame sometimes kills emacs


From: Stefan Monnier
Subject: Re: Killing a frame sometimes kills emacs
Date: Thu, 17 Nov 2011 21:05:14 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux)

> I did that by using the patch below for about one month.  Since then,
> the crashes I had are gone, and working with multiple emacs X frames is
> fun again.  Should I go ahead and commit?

Good news, thanks.

> --8<---------------cut here---------------start------------->8---
> === modified file 'src/frame.c'
> --- src/frame.c 2011-11-17 09:09:20 +0000
> +++ src/frame.c 2011-11-17 10:05:11 +0000
> @@ -1358,7 +1358,11 @@
 
>      /* If needed, delete the terminal that this frame was on.
>         (This must be done after the frame is killed.) */
> -    terminal->reference_count--;
> +
> +    // FIXME: Deleting the terminal crashes emacs because of a GTK
> +    // bug.  See the thread starting with <address@hidden>
> +    // on emacs-devel.
> +    // terminal->reference_count--;
>      if (terminal->reference_count == 0)
>        {
>         Lisp_Object tmp;
> --8<---------------cut here---------------end--------------->8---

To avoid the risk of reaching 0 via wrap-around (yes, I know that
creating a billion frames in the life of a single session is unlikely,
but still), you could do:

     /* If needed, delete the terminal that this frame was on.
        (This must be done after the frame is killed.) */
     terminal->reference_count--;
#ifdef USE_GTK
    /* ... (Use C-style not C++ style comments) ... */
    if (terminal->reference_count == 0 && terminal->type == output_x_window)
      terminal->reference_count = 1;
#endif
     if (terminal->reference_count == 0)
       {
        Lisp_Object tmp;

Alternatively you could get the same result by changing the code that
initializes terminal->reference_count so that it starts at 1 rather than
at 0.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]