Subject: Re: bug#18136: 24.4.50; crash in redisplay when calling load-theme

From: Eli Zaretskii <[email-masked]>
Date: Tue, 29 Jul 2014 17:47:47 +0300

> Date: Tue, 29 Jul 2014 16:02:13 +0200
> From: martin rudalics <[email-masked]>
> CC: [email-masked], [email-masked]
> 
>  > Why does it make sense to do that for TTY frames?  The terminal screen
>  > cannot be resized from within Emacs, so the arguments for treating the
>  > menu bar as an add-on are not really valid in this case.
> 
> The idea is that `frame-height' should have the same semantics on all
> platforms.  If you think we can ignore this difference for TTY frames
> I'm obviously OK with it.

I don't have strong feelings about it, and will probably adapt if we
stay with this semantics.  But it feels strange, as on a TTY the menu
bar is a line just like any other line, and when the menu bar is not
displayed, I'd expect that line to be used for text.

E.g., with your suggested semantics, what would you expect from this:

  emacs -Q
  M-: (frame-height) RET
  M-x menu-bar-mode RET
  M-: (frame-height) RET

Would you expect to see the 2 results of frame-height identical or
different?

The current trunk displays 2 identical results, and actually resizes
the root window to be consistent with that, so that there's an unused
empty line below the echo area.  Is that intended?  It looks like a
misfeature to me.

>  >> Probably this assignment
>  >>
>  >>         if ((FRAME_TERMCAP_P (f) && !pretend) || FRAME_MSDOS_P (f))
>  >> 	FrameCols (FRAME_TTY (f)) = new_cols;
>  >>
>  >> is completely misplaced and should be either removed or inhibited when
>  >> called from change_frame_size_1, that is when INHIBIT equals 5.  Can you
>  >> tell me what this assignment is for?
>  >
>  > It cannot be removed or inhibited.
> 
> Inhibited exclusively for the case that this function is called from
> change_frame_size (that is when INHIBIT equals 5).

You can't: this case is _precisely_ the case where we do need to
update FrameCols and FrameRows.

>  > It was introduced to fix a bug
>  > (#17875).  The problem is that different TTY frames on the same
>  > terminal can potentially have different dimensions, and OTOH FrameCols
>  > and FrameRows are "normally" set only at terminal initiation and in
>  > response to a SIGWINCH signal.  These assignments take care of keeping
>  > FrameCols and FrameRows in sync with frame dimensions in all other
>  > cases, because they all go through change_frame_size.
> 
> Which means FrameCols and FrameRows always have the correct values when
> entering adjust_frame_size

No, they don't, at least not necessarily.  If they did, what would be
the point of adding that to fix the bug?

Again, FrameRows and FrameCols updates are triggered in 3 possible
ways:

  . when the terminal is created

  . when we get SIGWINCH

  . when we call change_frame_size

The last one was missing, which caused bug #17875, whereby switching
to a different frame on the same terminal failed to update FrameRows
and FrameCols, because neither of the first 2 triggers happened.