Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit fd5aab3

Browse files
committed
[22190] Ensure setting spaceAbove does not affect spaceBelow
1 parent 05fb753 commit fd5aab3

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

docs/notes/bugfix-22190.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure setting the spaceAbove does not change the existing value of spaceBelow property

engine/src/exec-interface-field-chunk.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,11 @@ static void setparagraphattr_int16(MCParagraphAttrs*& attrs, uint32_t p_flag, si
12991299
setparagraphattr_int<int16_t, INT16_MIN, INT16_MAX>(attrs, p_flag, p_field_offset, (int16_t *)p_value);
13001300
}
13011301

1302+
static void setparagraphattr_uint16(MCParagraphAttrs*& attrs, uint32_t p_flag, size_t p_field_offset, uinteger_t *p_value)
1303+
{
1304+
setparagraphattr_int<uint16_t, 0, UINT16_MAX>(attrs, p_flag, p_field_offset, (uint16_t *)p_value);
1305+
}
1306+
13021307
static void setparagraphattr_color(MCParagraphAttrs*& attrs, uint32_t p_flag, size_t p_field_offset, const MCInterfaceNamedColor& p_color)
13031308
{
13041309
MCColor t_color;
@@ -2733,7 +2738,7 @@ void MCParagraph::GetEffectiveSpaceAbove(MCExecContext& ctxt, uinteger_t& r_spac
27332738

27342739
void MCParagraph::SetSpaceAbove(MCExecContext& ctxt, uinteger_t *p_space)
27352740
{
2736-
setparagraphattr_int<uinteger_t, 0, 32767>(attrs, PA_HAS_SPACE_ABOVE, offsetof(MCParagraphAttrs, space_above), p_space);
2741+
setparagraphattr_uint16(attrs, PA_HAS_SPACE_ABOVE, offsetof(MCParagraphAttrs, space_above), p_space);
27372742
}
27382743

27392744
void MCParagraph::GetSpaceBelow(MCExecContext& ctxt, uinteger_t *&r_space)
@@ -2751,7 +2756,7 @@ void MCParagraph::GetEffectiveSpaceBelow(MCExecContext& ctxt, uinteger_t& r_spac
27512756

27522757
void MCParagraph::SetSpaceBelow(MCExecContext& ctxt, uinteger_t *p_space)
27532758
{
2754-
setparagraphattr_int<uinteger_t, 0, 32767>(attrs, PA_HAS_SPACE_BELOW, offsetof(MCParagraphAttrs, space_below), p_space);
2759+
setparagraphattr_uint16(attrs, PA_HAS_SPACE_BELOW, offsetof(MCParagraphAttrs, space_below), p_space);
27552760
}
27562761

27572762
void MCParagraph::DoSetTabStops(MCExecContext &ctxt, bool p_is_relative, const vector_t<uinteger_t>& p_tabs)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
script "CoreFieldSpaceAbove"
2+
/*
3+
Copyright (C) 2019 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
on TestSpaceAboveAndSpaceBelow
20+
21+
open this stack
22+
create fld "myFld"
23+
put "Line one & return & Line 2 & return & Line 3" into fld "myFld"
24+
TestAssert "getting the effective spaceAbove of line 2", the effective spaceAbove of line 2 of fld "myFld" is 0
25+
TestAssert "getting the effective spaceBelow of line 2", the effective spaceBelow of line 2 of fld "myFld" is 0
26+
27+
local tSpaceAbove, tSpaceBelow
28+
29+
put random(5) into tSpaceAbove
30+
set the spaceAbove of line 2 of fld "myFld" to tSpaceAbove
31+
TestAssert "Setting the spaceAbove of line 2", the spaceAbove of line 2 of fld "myFld" is tSpaceAbove
32+
33+
put random(5) into tSpaceBelow
34+
set the spaceBelow of line 2 of fld "myFld" to tSpaceBelow
35+
TestAssert "Setting the spaceBelow of line 2", the spaceBelow of line 2 of fld "myFld" is tSpaceBelow
36+
37+
put random(5) into tSpaceAbove
38+
set the spaceAbove of line 2 of fld "myFld" to tSpaceAbove
39+
TestAssert "Setting the spaceAbove of line 2 does not affect the spaceBelow", the spaceBelow of line 2 of fld "myFld" is tSpaceBelow
40+
41+
put random(5) into tSpaceBelow
42+
set the spaceBelow of line 2 of fld "myFld" to tSpaceBelow
43+
TestAssert "Setting the spaceBelow of line 2 does not affect the spaceAbove", the spaceAbove of line 2 of fld "myFld" is tSpaceAbove
44+
45+
delete fld "myFld"
46+
end TestSpaceAboveAndSpaceBelow

0 commit comments

Comments
 (0)