all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#10955: 24.0.94; Closing Speedbar frame raises error
@ 2012-03-06 11:00 Stephen Berman
  2012-03-06 15:36 ` martin rudalics
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Berman @ 2012-03-06 11:00 UTC (permalink / raw)
  To: 10955

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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#10955: 24.0.94; Closing Speedbar frame raises error
  2012-03-06 11:00 bug#10955: 24.0.94; Closing Speedbar frame raises error Stephen Berman
@ 2012-03-06 15:36 ` martin rudalics
  2012-03-06 16:04   ` Stephen Berman
  2012-03-10  7:50   ` Chong Yidong
  0 siblings, 2 replies; 4+ messages in thread
From: martin rudalics @ 2012-03-06 15:36 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 10955

[-- Attachment #1: Type: text/plain, Size: 3208 bytes --]

 > 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

[-- Attachment #2: frame.c.diff --]
[-- Type: text/plain, Size: 755 bytes --]

=== 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;
 }



^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#10955: 24.0.94; Closing Speedbar frame raises error
  2012-03-06 15:36 ` martin rudalics
@ 2012-03-06 16:04   ` Stephen Berman
  2012-03-10  7:50   ` Chong Yidong
  1 sibling, 0 replies; 4+ messages in thread
From: Stephen Berman @ 2012-03-06 16:04 UTC (permalink / raw)
  To: martin rudalics; +Cc: 10955

On Tue, 06 Mar 2012 16:36:17 +0100 martin rudalics <rudalics@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#10955: 24.0.94; Closing Speedbar frame raises error
  2012-03-06 15:36 ` martin rudalics
  2012-03-06 16:04   ` Stephen Berman
@ 2012-03-10  7:50   ` Chong Yidong
  1 sibling, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2012-03-10  7:50 UTC (permalink / raw)
  To: martin rudalics; +Cc: Stephen Berman, 10955

martin rudalics <rudalics@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-03-10  7:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-06 11:00 bug#10955: 24.0.94; Closing Speedbar frame raises error Stephen Berman
2012-03-06 15:36 ` martin rudalics
2012-03-06 16:04   ` Stephen Berman
2012-03-10  7:50   ` Chong Yidong

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.