aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
authorEli Zaretskii2014-09-24 10:31:11 +0300
committerEli Zaretskii2014-09-24 10:31:11 +0300
commita45a7f5d1aeed7845f56cf56382c625445fbb583 (patch)
treeacb89f82bf711a67f928234e35871d8dd23cadda /src/w32term.c
parentfc5ebc3f497a152132407d57a14cce147d59d29c (diff)
downloademacs-a45a7f5d1aeed7845f56cf56382c625445fbb583.tar.gz
emacs-a45a7f5d1aeed7845f56cf56382c625445fbb583.zip
Fix bug #18528 with crashes at startup during frameset restoration.
src/w32term.c (w32_read_socket): Don't use frame dimensions for resizing if GetClientRect returned an empty (0, 0, 0, 0) rectangle. Check the return value of GetClientRect, and don't use the results if it didn't succeed. src/dispnew.c (change_frame_size_1): Recompute the frame dimensions in columns and lines after correcting the pixel dimensions in check_frame_size. (adjust_decode_mode_spec_buffer): Add assertion to avoid passing negative values to xrealloc.
Diffstat (limited to 'src/w32term.c')
-rw-r--r--src/w32term.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 5f15798eeeb..5a053b4fc0d 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4754,34 +4754,42 @@ w32_read_socket (struct terminal *terminal,
4754 RECT rect; 4754 RECT rect;
4755 int rows, columns, width, height, text_width, text_height; 4755 int rows, columns, width, height, text_width, text_height;
4756 4756
4757 GetClientRect (msg.msg.hwnd, &rect); 4757 if (GetClientRect (msg.msg.hwnd, &rect)
4758 4758 /* GetClientRect evidently returns (0, 0, 0, 0) if
4759 height = rect.bottom - rect.top; 4759 called on a minimized frame. Such "dimensions"
4760 width = rect.right - rect.left; 4760 aren't useful anyway. */
4761 text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, width); 4761 && !(rect.bottom == 0
4762 text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, height); 4762 && rect.top == 0
4763 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height); 4763 && rect.left == 0
4764 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width); 4764 && rect.right == 0))
4765
4766 /* TODO: Clip size to the screen dimensions. */
4767
4768 /* Even if the number of character rows and columns has
4769 not changed, the font size may have changed, so we need
4770 to check the pixel dimensions as well. */
4771
4772 if (width != FRAME_PIXEL_WIDTH (f)
4773 || height != FRAME_PIXEL_HEIGHT (f)
4774 || text_width != FRAME_TEXT_WIDTH (f)
4775 || text_height != FRAME_TEXT_HEIGHT (f))
4776 { 4765 {
4777 change_frame_size (f, text_width, text_height, 0, 1, 0, 1); 4766 height = rect.bottom - rect.top;
4778 SET_FRAME_GARBAGED (f); 4767 width = rect.right - rect.left;
4779 cancel_mouse_face (f); 4768 text_width = FRAME_PIXEL_TO_TEXT_WIDTH (f, width);
4780 /* Do we want to set these here ???? */ 4769 text_height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, height);
4781/** FRAME_PIXEL_WIDTH (f) = width; **/ 4770 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
4782/** FRAME_TEXT_WIDTH (f) = text_width; **/ 4771 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
4783/** FRAME_PIXEL_HEIGHT (f) = height; **/ 4772
4784 f->win_gravity = NorthWestGravity; 4773 /* TODO: Clip size to the screen dimensions. */
4774
4775 /* Even if the number of character rows and columns
4776 has not changed, the font size may have changed,
4777 so we need to check the pixel dimensions as well. */
4778
4779 if (width != FRAME_PIXEL_WIDTH (f)
4780 || height != FRAME_PIXEL_HEIGHT (f)
4781 || text_width != FRAME_TEXT_WIDTH (f)
4782 || text_height != FRAME_TEXT_HEIGHT (f))
4783 {
4784 change_frame_size (f, text_width, text_height, 0, 1, 0, 1);
4785 SET_FRAME_GARBAGED (f);
4786 cancel_mouse_face (f);
4787 /* Do we want to set these here ???? */
4788 /** FRAME_PIXEL_WIDTH (f) = width; **/
4789 /** FRAME_TEXT_WIDTH (f) = text_width; **/
4790 /** FRAME_PIXEL_HEIGHT (f) = height; **/
4791 f->win_gravity = NorthWestGravity;
4792 }
4785 } 4793 }
4786 } 4794 }
4787 4795