Subject: Re: 24.3.93; Crash during restoration of frameset from desktop

From: Eli Zaretskii <[email-masked]>
Date: Tue, 23 Sep 2014 18:26:27 +0300

> Date: Tue, 23 Sep 2014 07:48:40 +0200
> From: martin rudalics <[email-masked]>
> CC: [email-masked]
> 
>  > I certainly think so.  If GetClientRect fails, how does it make sense
>  > to use what we find in the rectangle data structure we passed to it?
>  > The values there are just garbage.
> 
> We have to check these values anyway because our window structure might
> be too complex to fit into the rectangle returned by GetClientRect.

Sorry, I don't think I understand this.  GetClientRect just returns
the dimensions of our frame, it doesn't know anything about Emacs
windows.

> But then we should probably also rewrite things like
> w32_clear_window as
> 
>    if (hdc && GetClientRect (FRAME_W32_WINDOW (f), &rect))
>      w32_clear_rect (f, hdc, &rect);

Indeed.

>  >>   > +  /* Recompute the dimensions in character units, since
>  >>   > +     check_frame_size might have changed the pixel dimensions.  */
>  >>   > +  /* Consider rounding here: Currently, the root window can be
>  >>   > +     larger than the frame in terms of columns/lines.  */
>  >>   > +  new_cols = new_text_width / FRAME_COLUMN_WIDTH (f);
>  >>   > +  new_lines = new_text_height / FRAME_LINE_HEIGHT (f);
> 
> I never got around to ask you: Do you anywhere see a need to round up
> the values of new_cols and new_lines in cases like this?

Yes, I think so.  I think the reason we didn't see any problems with
that is that GUI windows always over-allocate their glyph matrices, to
be prepared for dealing with the smallest possible font, which is
rarely if ever used.  But I think if you actually use that smallest
font for the default face, you will see the problem.

(Just make sure you don't round up for TTY frames, so as not to add
one extra row there.)