aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/ChangeLog13
-rw-r--r--src/dispnew.c15
-rw-r--r--src/w32term.c62
3 files changed, 58 insertions, 32 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4d969d73279..a5c25ab7168 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
12014-09-24 Eli Zaretskii <eliz@gnu.org>
2
3 * w32term.c (w32_read_socket): Don't use frame dimensions for
4 resizing if GetClientRect returned an empty (0, 0, 0, 0)
5 rectangle. Check the return value of GetClientRect, and don't use
6 the results if it didn't succeed.
7
8 * dispnew.c (change_frame_size_1): Recompute the frame dimensions
9 in columns and lines after correcting the pixel dimensions in
10 check_frame_size.
11 (adjust_decode_mode_spec_buffer): Add assertion to avoid passing
12 negative values to xrealloc. (Bug#18528)
13
12014-09-22 Dmitry Antipov <dmantipov@yandex.ru> 142014-09-22 Dmitry Antipov <dmantipov@yandex.ru>
2 15
3 On OSX, do not free font-specific data more than once (Bug#18501). 16 On OSX, do not free font-specific data more than once (Bug#18501).
diff --git a/src/dispnew.c b/src/dispnew.c
index 5bdcb279be7..71345775045 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -2138,8 +2138,11 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f)
2138static void 2138static void
2139adjust_decode_mode_spec_buffer (struct frame *f) 2139adjust_decode_mode_spec_buffer (struct frame *f)
2140{ 2140{
2141 ssize_t frame_message_buf_size = FRAME_MESSAGE_BUF_SIZE (f);
2142
2143 eassert (frame_message_buf_size >= 0);
2141 f->decode_mode_spec_buffer = xrealloc (f->decode_mode_spec_buffer, 2144 f->decode_mode_spec_buffer = xrealloc (f->decode_mode_spec_buffer,
2142 FRAME_MESSAGE_BUF_SIZE (f) + 1); 2145 frame_message_buf_size + 1);
2143} 2146}
2144 2147
2145 2148
@@ -5539,10 +5542,6 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
5539 { 5542 {
5540 new_text_width = (new_width == 0) ? FRAME_TEXT_WIDTH (f) : new_width; 5543 new_text_width = (new_width == 0) ? FRAME_TEXT_WIDTH (f) : new_width;
5541 new_text_height = (new_height == 0) ? FRAME_TEXT_HEIGHT (f) : new_height; 5544 new_text_height = (new_height == 0) ? FRAME_TEXT_HEIGHT (f) : new_height;
5542 /* Consider rounding here: Currently, the root window can be
5543 larger than the frame in terms of columns/lines. */
5544 new_cols = new_text_width / FRAME_COLUMN_WIDTH (f);
5545 new_lines = new_text_height / FRAME_LINE_HEIGHT (f);
5546 } 5545 }
5547 else 5546 else
5548 { 5547 {
@@ -5555,6 +5554,12 @@ change_frame_size_1 (struct frame *f, int new_width, int new_height,
5555 /* Compute width of windows in F. */ 5554 /* Compute width of windows in F. */
5556 /* Round up to the smallest acceptable size. */ 5555 /* Round up to the smallest acceptable size. */
5557 check_frame_size (f, &new_text_width, &new_text_height, 1); 5556 check_frame_size (f, &new_text_width, &new_text_height, 1);
5557 /* Recompute the dimensions in character units, since
5558 check_frame_size might have changed the pixel dimensions. */
5559 /* Consider rounding here: Currently, the root window can be
5560 larger than the frame in terms of columns/lines. */
5561 new_cols = new_text_width / FRAME_COLUMN_WIDTH (f);
5562 new_lines = new_text_height / FRAME_LINE_HEIGHT (f);
5558 5563
5559 /* This is the width of the frame without vertical scroll bars and 5564 /* This is the width of the frame without vertical scroll bars and
5560 fringe columns. Do this after rounding - see discussion of 5565 fringe columns. Do this after rounding - see discussion of
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