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

Commit 3435327

Browse files
Merge pull request #7107 from livecodepanos/bugfix-22190_2
[22190] Ensure setting spaceAbove does not affect spaceBelow
2 parents 47ef8d9 + fd5aab3 commit 3435327

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
@@ -1300,6 +1300,11 @@ static void setparagraphattr_int16(MCParagraphAttrs*& attrs, uint32_t p_flag, si
13001300
setparagraphattr_int<int16_t, INT16_MIN, INT16_MAX>(attrs, p_flag, p_field_offset, (int16_t *)p_value);
13011301
}
13021302

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

27352740
void MCParagraph::SetSpaceAbove(MCExecContext& ctxt, uinteger_t *p_space)
27362741
{
2737-
setparagraphattr_int<uinteger_t, 0, 32767>(attrs, PA_HAS_SPACE_ABOVE, offsetof(MCParagraphAttrs, space_above), p_space);
2742+
setparagraphattr_uint16(attrs, PA_HAS_SPACE_ABOVE, offsetof(MCParagraphAttrs, space_above), p_space);
27382743
}
27392744

27402745
void MCParagraph::GetSpaceBelow(MCExecContext& ctxt, uinteger_t *&r_space)
@@ -2752,7 +2757,7 @@ void MCParagraph::GetEffectiveSpaceBelow(MCExecContext& ctxt, uinteger_t& r_spac
27522757

27532758
void MCParagraph::SetSpaceBelow(MCExecContext& ctxt, uinteger_t *p_space)
27542759
{
2755-
setparagraphattr_int<uinteger_t, 0, 32767>(attrs, PA_HAS_SPACE_BELOW, offsetof(MCParagraphAttrs, space_below), p_space);
2760+
setparagraphattr_uint16(attrs, PA_HAS_SPACE_BELOW, offsetof(MCParagraphAttrs, space_below), p_space);
27562761
}
27572762

27582763
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)