GNU bug report logs - #10955
24.0.94; Closing Speedbar frame raises error

Previous Next

Package: emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Tue, 6 Mar 2012 11:03:02 UTC

Severity: normal

Found in version 24.0.94

Done: Chong Yidong <cyd <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10955 in the body.
You can then email your comments to 10955 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#10955; Package emacs. (Tue, 06 Mar 2012 11:03:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stephen Berman <stephen.berman <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 06 Mar 2012 11:03:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.94; Closing Speedbar frame raises error
Date: Tue, 06 Mar 2012 12:00:51 +0100
0. emacs -Q
1. Check "Enter Debugger on Error" in the Options menu.
2. M-x speedbar
3. With the Speedbar frame selected, type `q'.
=>The Speedbar frame vanishes, and in the remaining frame, the following
backtrace appears:

Debugger entered--Lisp error: (error "Attempt to delete the sole visible or iconified frame")
  delete-frame(#<frame Speedbar 1.0 0x89f3f80>)
  window--delete(#<window 8 on  SPEEDBAR> t t)
  replace-buffer-in-windows(#<buffer  SPEEDBAR>)
  kill-buffer(#<buffer  SPEEDBAR>)
  dframe-close-frame()
  call-interactively(dframe-close-frame nil nil)

No error is raised if steps 0-2 are repeated and at step 3 `Q'
(delete-frame) is typed.

Note that the frame consists of a single window containing the
*Backtrace* buffer (normally, a backtrace splits the window).  Moreover,
typing `q' (top-level) in this buffer deletes the backtrace, but an
empty *Backtrace* buffer remains as the current buffer (normally, `q'
kills the *Backtrace* buffer.)


In GNU Emacs 24.0.94.4 (i686-suse-linux-gnu, GTK+ Version 2.24.7)
 of 2012-03-06 on escher
Windowing system distributor `The X.Org Foundation', version 11.0.11004000
Configured using:
 `configure '--without-toolkit-scroll-bars' 'CFLAGS=-g''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10955; Package emacs. (Tue, 06 Mar 2012 15:38:01 GMT) Full text and rfc822 format available.

Message #8 received at 10955 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Stephen Berman <stephen.berman <at> gmx.net>
Cc: 10955 <at> debbugs.gnu.org
Subject: Re: bug#10955: 24.0.94; Closing Speedbar frame raises error
Date: Tue, 06 Mar 2012 16:36:17 +0100
[Message part 1 (text/plain, inline)]
> 0. emacs -Q
> 1. Check "Enter Debugger on Error" in the Options menu.
> 2. M-x speedbar
> 3. With the Speedbar frame selected, type `q'.
> =>The Speedbar frame vanishes, and in the remaining frame, the following
> backtrace appears:
>
> Debugger entered--Lisp error: (error "Attempt to delete the sole visible or iconified frame")
>   delete-frame(#<frame Speedbar 1.0 0x89f3f80>)
>   window--delete(#<window 8 on  SPEEDBAR> t t)
>   replace-buffer-in-windows(#<buffer  SPEEDBAR>)
>   kill-buffer(#<buffer  SPEEDBAR>)
>   dframe-close-frame()
>   call-interactively(dframe-close-frame nil nil)
>
> No error is raised if steps 0-2 are repeated and at step 3 `Q'
> (delete-frame) is typed.
>
> Note that the frame consists of a single window containing the
> *Backtrace* buffer (normally, a backtrace splits the window).  Moreover,
> typing `q' (top-level) in this buffer deletes the backtrace, but an
> empty *Backtrace* buffer remains as the current buffer (normally, `q'
> kills the *Backtrace* buffer.)

At the time `window--delete' is called the speedbar frame is invisible
(you should be able to verify this by calling

  (frame-visible-p (window-frame window))

right at the beginning of `window--delete').  `dframe-frame-mode' has

	      (make-frame-invisible (symbol-value frame-var))))

and so we have found someone responsible for this behavior.  Now there's
nothing wrong with making a frame invisible and then trying to delete
it.  What happens, however, is that `delete-frame' is determined to
delete a frame if and only if there are "other visible frames" which
sounds like a reasonable condition.  Unfortunately, it's implementation
seems wrong.  Look at the code below called for the invisible frame f:

other_visible_frames (FRAME_PTR f)
{
  /* We know the selected frame is visible,
     so if F is some other frame, it can't be the sole visible one.  */
  if (f == SELECTED_FRAME ()) <---- f is selected, so we take this
    {
      Lisp_Object frames;
      int count = 0; <---- we set this to zero

      for (frames = Vframe_list; <---- there are two frames, a visible and an invisible one
	   CONSP (frames);
	   frames = XCDR (frames))
	{
	  Lisp_Object this;

	  this = XCAR (frames);
	  /* Verify that the frame's window still exists
	     and we can still talk to it.  And note any recent change
	     in visibility.  */
#ifdef HAVE_WINDOW_SYSTEM
	  if (FRAME_WINDOW_P (XFRAME (this)))
	    {
	      x_sync (XFRAME (this));
	      FRAME_SAMPLE_VISIBILITY (XFRAME (this));
	    }
#endif

	  if (FRAME_VISIBLE_P (XFRAME (this)) <---- Neither of these three disjuncts holds for f
	      || FRAME_ICONIFIED_P (XFRAME (this))
	      /* Allow deleting the terminal frame when at least
		 one X frame exists!  */
	      || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f)))
	    count++; <---- incremented once only, for the sole visible frame
	}
      return count > 1; <---- fails since count == 1
    }
  return 1;
}

So this code makes it impossible to delete an invisible (or iconified)
frame if it's selected and there is only one other visible frame.  The
attached patch should fix this but I'm not very sure whether it's
correct.

martin
[frame.c.diff (text/plain, inline)]
=== modified file 'src/frame.c'
--- src/frame.c	2012-01-19 07:21:25 +0000
+++ src/frame.c	2012-03-06 15:18:55 +0000
@@ -1143,14 +1143,15 @@
 	    }
 #endif
 
-	  if (FRAME_VISIBLE_P (XFRAME (this))
-	      || FRAME_ICONIFIED_P (XFRAME (this))
-	      /* Allow deleting the terminal frame when at least
-		 one X frame exists!  */
-	      || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f)))
+	  if (f != XFRAME (this)
+	      && (FRAME_VISIBLE_P (XFRAME (this))
+		  || FRAME_ICONIFIED_P (XFRAME (this))
+		  /* Allow deleting the terminal frame when at least
+		     one X frame exists!  */
+		  || (FRAME_WINDOW_P (XFRAME (this)) && !FRAME_WINDOW_P (f))))
 	    count++;
 	}
-      return count > 1;
+      return count;
     }
   return 1;
 }



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10955; Package emacs. (Tue, 06 Mar 2012 16:06:02 GMT) Full text and rfc822 format available.

Message #11 received at 10955 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 10955 <at> debbugs.gnu.org
Subject: Re: bug#10955: 24.0.94; Closing Speedbar frame raises error
Date: Tue, 06 Mar 2012 17:04:27 +0100
On Tue, 06 Mar 2012 16:36:17 +0100 martin rudalics <rudalics <at> gmx.at> wrote:

>> 0. emacs -Q
>> 1. Check "Enter Debugger on Error" in the Options menu.
>> 2. M-x speedbar
>> 3. With the Speedbar frame selected, type `q'.
>> =>The Speedbar frame vanishes, and in the remaining frame, the following
>> backtrace appears:
>>
>> Debugger entered--Lisp error: (error "Attempt to delete the sole visible or
>> iconified frame")
>>   delete-frame(#<frame Speedbar 1.0 0x89f3f80>)
>>   window--delete(#<window 8 on  SPEEDBAR> t t)
>>   replace-buffer-in-windows(#<buffer  SPEEDBAR>)
>>   kill-buffer(#<buffer  SPEEDBAR>)
>>   dframe-close-frame()
>>   call-interactively(dframe-close-frame nil nil)
[...]
> So this code makes it impossible to delete an invisible (or iconified)
> frame if it's selected and there is only one other visible frame.  The
> attached patch should fix this but I'm not very sure whether it's
> correct.

I also can't say if it's the best fix, but I confirm that with it I
don't see the error I reported.

Steve Berman




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10955; Package emacs. (Sat, 10 Mar 2012 08:21:01 GMT) Full text and rfc822 format available.

Message #14 received at 10955 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> gnu.org>
To: martin rudalics <rudalics <at> gmx.at>
Cc: Stephen Berman <stephen.berman <at> gmx.net>, 10955 <at> debbugs.gnu.org
Subject: Re: bug#10955: 24.0.94; Closing Speedbar frame raises error
Date: Sat, 10 Mar 2012 15:50:42 +0800
martin rudalics <rudalics <at> gmx.at> writes:

> So this code makes it impossible to delete an invisible (or iconified)
> frame if it's selected and there is only one other visible frame.  The
> attached patch should fix this but I'm not very sure whether it's
> correct.

Thanks for the analysis, Martin.  Judging by the comments in
other_visible_frames, the logic was basically out of date in assuming
the selected frame can't be invisible.  I checked in a slightly more
aggressive rewrite that clears this up.




bug closed, send any further explanations to 10955 <at> debbugs.gnu.org and Stephen Berman <stephen.berman <at> gmx.net> Request was from Chong Yidong <cyd <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 10 Mar 2012 08:21:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 07 Apr 2012 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 31 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.