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

Commit 1af86eb

Browse files
committed
[[ Bug 19703 ]] Changed lockedness check from default stack to current stack
1 parent 23c0a59 commit 1af86eb

File tree

7 files changed

+55
-13
lines changed

7 files changed

+55
-13
lines changed

docs/dictionary/command/create-card.lcdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ stack>.
4747

4848
The new card is placed after the current card. If <stackName>
4949
is specified, it will be placed in <stackName>, otherwise
50-
in defualtStack When the <card> is created, you go to the new <card>.
50+
in the <defaultStack>. When the <card> is created, you go to the new <card>.
5151

5252
Any groups on the current card whose backgroundBehavior is set to true
5353
will be placed on the newly-created <card> automatically.

docs/dictionary/command/create-widget.lcdoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Name: create widget
22

33
Type: command
44

5-
Syntax: create [invisible] widget [<controlName>] as <widgetKind> [in <group>]
5+
Syntax: create [invisible] widget [<controlName>] as <widgetKind> [in {<group>|<card>}]
66

77
Summary:
88
Create a <widget> control of the specified <kind>.
@@ -40,6 +40,12 @@ of the <group>, and exists on each <card> that has the <group>. If you
4040
don't specify a <group>, the <widget> is created on the current <card>
4141
and appears only on that <card>.
4242

43+
card:
44+
A reference or an expression that evaluates to a reference to a card.
45+
If you specify a card, the new <widget> is a member of the <card>.
46+
If you specify neither a <group> nor a <card>, the <widget>
47+
is created on the current <card> and appears only on that <card>.
48+
4349
It:
4450
The <create widget> command places the ID property of the newly created
4551
<widget> in the <it> variable.

docs/dictionary/command/create.lcdoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Synonyms: new
44

55
Type: command
66

7-
Syntax: create [invisible] <objectType> [<objectName>] [in {group|card}]
7+
Syntax: create [invisible] <objectType> [<objectName>] [in {<group>|<card>}]
88

99
Summary:
1010
Creates a new object on the current card.
@@ -43,7 +43,7 @@ group:
4343
A reference or and expression that evaluates to a reference to a
4444
group on the current card. If you specify a group, the new object is a
4545
member of the group, and exists on each card that has the group. If you
46-
don't specify neither a group nor a card, the object is created on the
46+
specify neither a group nor a card, the object is created on the
4747
current card and appears only on that card.
4848

4949
card:

engine/src/cmdsc.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,14 @@ void MCCreate::exec_ctxt(MCExecContext& ctxt)
643643
{
644644
uint32_t parid;
645645

646-
if (!container->getobj(ctxt, parent, parid, True) || parent->gettype() != CT_GROUP)
646+
if (!container->getobj(ctxt, parent, parid, True)
647+
|| (parent->gettype() != CT_GROUP && parent->gettype() != CT_CARD))
647648
{
648649
ctxt . LegacyThrow(EE_CREATE_BADBGORCARD);
649650
return;
650651
}
651652
}
652-
MCInterfaceExecCreateWidget(ctxt, *t_new_name, *t_kind, (MCGroup *)parent, visible == False);
653+
MCInterfaceExecCreateWidget(ctxt, *t_new_name, *t_kind, parent, visible == False);
653654
break;
654655
}
655656
default:
@@ -666,7 +667,7 @@ void MCCreate::exec_ctxt(MCExecContext& ctxt)
666667
return;
667668
}
668669
}
669-
MCInterfaceExecCreateControl(ctxt, *t_new_name, otype, (MCGroup *)parent, visible == False);
670+
MCInterfaceExecCreateControl(ctxt, *t_new_name, otype, parent, visible == False);
670671
}
671672
break;
672673
}

engine/src/exec-interface.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3330,7 +3330,10 @@ MCControl* MCInterfaceExecCreateControlGetObject(MCExecContext& ctxt, int p_type
33303330

33313331
void MCInterfaceExecCreateControl(MCExecContext& ctxt, MCStringRef p_new_name, int p_type, MCObject *p_container, bool p_force_invisible)
33323332
{
3333-
if (MCdefaultstackptr->islocked())
3333+
3334+
MCStack *t_current_stack = p_container == nullptr ? MCdefaultstackptr : p_container->getstack();
3335+
3336+
if (t_current_stack->islocked())
33343337
{
33353338
ctxt . LegacyThrow(EE_CREATE_LOCKED);
33363339
return;
@@ -3367,9 +3370,12 @@ void MCInterfaceExecCreateControl(MCExecContext& ctxt, MCStringRef p_new_name, i
33673370
ctxt . SetItToValue(*t_id);
33683371
}
33693372

3370-
void MCInterfaceExecCreateWidget(MCExecContext& ctxt, MCStringRef p_new_name, MCNameRef p_kind, MCGroup* p_container, bool p_force_invisible)
3373+
void MCInterfaceExecCreateWidget(MCExecContext& ctxt, MCStringRef p_new_name, MCNameRef p_kind, MCObject* p_container, bool p_force_invisible)
33713374
{
3372-
if (MCdefaultstackptr->islocked())
3375+
3376+
MCStack *t_current_stack = p_container == nullptr ? MCdefaultstackptr : p_container->getstack();
3377+
3378+
if (t_current_stack->islocked())
33733379
{
33743380
ctxt . LegacyThrow(EE_CREATE_LOCKED);
33753381
return;

engine/src/exec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3121,7 +3121,7 @@ void MCInterfaceExecCreateScriptOnlyStack(MCExecContext& ctxt, MCStringRef p_new
31213121
void MCInterfaceExecCreateStackWithGroup(MCExecContext& ctxt, MCGroup *p_group_to_copy, MCStringRef p_new_name, bool p_force_invisible);
31223122
void MCInterfaceExecCreateCard(MCExecContext& ctxt, MCStringRef p_new_name, MCStack *p_parent, bool p_force_invisible);
31233123
void MCInterfaceExecCreateControl(MCExecContext& ctxt, MCStringRef p_new_name, int p_type, MCObject *p_container, bool p_force_invisible);
3124-
void MCInterfaceExecCreateWidget(MCExecContext& ctxt, MCStringRef p_new_name, MCNameRef p_kind, MCGroup *p_container, bool p_force_invisible);
3124+
void MCInterfaceExecCreateWidget(MCExecContext& ctxt, MCStringRef p_new_name, MCNameRef p_kind, MCObject *p_container, bool p_force_invisible);
31253125

31263126
void MCInterfaceExecClone(MCExecContext& ctxt, MCObject *p_target, MCStringRef p_new_name, bool p_force_invisible);
31273127

tests/lcs/core/interface/stack.livecodescript

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,41 @@ on TestCreateControlInCard
3939
TestAssert "test if the button was created in the correct card" , there is a button "Test" of card "Other"
4040
end TestCreateControlInCard
4141

42-
on TestCreateControlInStack
42+
on TestCreateCardInStack
4343
create stack "Temp"
4444
create stack "Temp2"
4545

4646
create card "Other" in stack "Temp"
4747

4848

4949
TestAssert "test if the card was created in the correct stack" , there is a card "Other" of stack "Temp"
50-
end TestCreateControlInStack
50+
end TestCreateCardInStack
51+
52+
on TestCreateWidgetInCard
53+
create stack "Temp"
54+
55+
create card "Other" in stack "Temp"
56+
create card "Other 2"
57+
58+
create widget "My Navbar" as "com.livecode.widget.navbar" in card "Other" of stack "Temp"
59+
60+
TestAssert "test if the widget was created in the correct card", there is a widget "My Navbar" of card "Other" of stack "Temp"
61+
end TestCreateWidgetInCard
62+
63+
on TestCreateControlInContainerWithDefaultStackLocked
64+
create stack "Temp"
65+
66+
set the cantModify of stack "Temp" to true
67+
68+
create stack "Temp2"
69+
70+
set the defaultStack to "Temp2"
71+
72+
create group "Bar"
73+
74+
set the defaultStack to "Temp"
75+
76+
create button "Foo" in group "Bar" of stack "Temp2"
77+
78+
TestAssert "testing no exceptions were thrown" , true
79+
end TestCreateControlInContainerWithDefaultStackLocked

0 commit comments

Comments
 (0)