Skip to content

Commit ab4b85d

Browse files
committed
Merge pull request livecode#3448 from livecodeali/bugfix-16351
[[ Bug 16351 ]] Make MCtargetptr an MCObjectPtr
2 parents bf3cf90 + ef98ff8 commit ab4b85d

27 files changed

Lines changed: 210 additions & 173 deletions

docs/notes/bugfix-16351.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# After a dispatch command, the long id of the target resolves correctly for shared groups and their children

engine/src/cardlst.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ bool MCCardlist::GetRecent(MCExecContext& ctxt, MCStack *stack, Properties which
8888
if (which == P_SHORT_NAME)
8989
tmp -> card -> GetShortName(ctxt, &t_property);
9090
else
91-
tmp -> card -> GetLongId(ctxt, &t_property);
91+
tmp -> card -> GetLongId(ctxt, 0, &t_property);
9292

9393
t_success = !ctxt . HasError();
9494
if (t_success)

engine/src/chunk.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,10 +902,12 @@ void MCChunk::getoptionalobj(MCExecContext& ctxt, MCObjectPtr &r_object, Boolean
902902
case DT_ME:
903903
//MCEngineEvalMeAsObject(ctxt, t_object);
904904
if (ctxt . GetParentScript() == NULL)
905+
{
905906
t_object . object = destobj;
907+
t_object . part_id = 0;
908+
}
906909
else
907-
t_object . object = ctxt . GetObject();
908-
t_object . part_id = 0;
910+
t_object = ctxt . GetObjectPtr();
909911
break;
910912
case DT_MENU_OBJECT:
911913
MCEngineEvalMenuObjectAsObject(ctxt, t_object);

engine/src/cmdsc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4433,13 +4433,15 @@ void MCRelayer::exec_ctxt(MCExecContext& ctxt)
44334433
MCInterfaceExecRelayer(ctxt, relation, t_source, t_layer);
44344434
break;
44354435
case kMCRelayerFormRelativeToControl:
4436+
{
44364437
MCObjectPtr t_target;
44374438
if (!target -> getobj(ctxt, t_target, True))
44384439
{
44394440
ctxt . LegacyThrow(EE_RELAYER_NOTARGET);
44404441
return;
44414442
}
44424443
MCInterfaceExecRelayerRelativeToControl(ctxt, relation, t_source, t_target);
4444+
}
44434445
break;
44444446
case kMCRelayerFormRelativeToOwner:
44454447
MCInterfaceExecRelayerRelativeToOwner(ctxt, relation, t_source);

engine/src/cmdss.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,7 @@ void MCHide::exec_ctxt(MCExecContext &ctxt)
16111611
MCInterfaceExecHideGroups(ctxt);
16121612
break;
16131613
case SO_OBJECT:
1614+
{
16141615
MCObjectPtr t_target;
16151616
if (!object->getobj(ctxt, t_target, True))
16161617
{
@@ -1621,6 +1622,7 @@ void MCHide::exec_ctxt(MCExecContext &ctxt)
16211622
MCInterfaceExecHideObjectWithEffect(ctxt, t_target, effect);
16221623
else
16231624
MCInterfaceExecHideObject(ctxt, t_target);
1625+
}
16241626
break;
16251627
case SO_MENU:
16261628
MCInterfaceExecHideMenuBar(ctxt);

engine/src/dispatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ Exec_stat MCDispatch::handle(Handler_type htype, MCNameRef mess, MCParameter *pa
373373
}
374374

375375
if (MCmessagemessages && stat != ES_PASS)
376-
MCtargetptr->sendmessage(htype, mess, False);
376+
MCtargetptr . object -> sendmessage(htype, mess, False);
377377

378378
if (t_has_passed)
379379
return ES_PASS;

engine/src/exec-engine.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -602,18 +602,18 @@ void MCEngineEvalMe(MCExecContext& ctxt, MCStringRef& r_string)
602602

603603
void MCEngineEvalTarget(MCExecContext& ctxt, MCStringRef& r_string)
604604
{
605-
if (MCtargetptr == nil)
605+
if (MCtargetptr . object == nil)
606606
r_string = MCValueRetain(kMCEmptyString);
607607
else
608-
MCtargetptr->getstringprop(ctxt, 0, P_NAME, False, r_string);
608+
MCtargetptr . object -> getstringprop(ctxt, MCtargetptr . part_id, P_NAME, False, r_string);
609609
}
610610

611611
void MCEngineEvalTargetContents(MCExecContext& ctxt, MCStringRef& r_string)
612612
{
613-
if (MCtargetptr == nil)
613+
if (MCtargetptr . object == nil)
614614
r_string = MCValueRetain(kMCEmptyString);
615615
else
616-
MCtargetptr->getstringprop(ctxt, 0, MCtargetptr->gettype() == CT_FIELD ? P_TEXT : P_NAME, False, r_string);
616+
MCtargetptr . object -> getstringprop(ctxt, MCtargetptr . part_id, MCtargetptr . object -> gettype() == CT_FIELD ? P_TEXT : P_NAME, False, r_string);
617617
}
618618

619619
//////////
@@ -1169,22 +1169,22 @@ void MCEngineExecDispatch(MCExecContext& ctxt, int p_handler_type, MCNameRef p_m
11691169
}
11701170

11711171
// Work out the target object
1172-
MCObject *t_object;
1172+
MCObjectPtr t_object;
11731173
if (p_target != nil)
1174-
t_object = p_target -> object;
1174+
t_object = *p_target;
11751175
else
1176-
t_object = ctxt . GetObject();
1176+
t_object = ctxt . GetObjectPtr();
11771177

11781178
// Fetch current default stack and target settings
11791179
MCStack *t_old_stack;
11801180
t_old_stack = MCdefaultstackptr;
1181-
MCObject *t_old_target;
1181+
MCObjectPtr t_old_target;
11821182
t_old_target = MCtargetptr;
11831183

11841184
// Cache the current 'this stack' (used to see if we should switch back
11851185
// the default stack).
11861186
MCStack *t_this_stack;
1187-
t_this_stack = t_object -> getstack();
1187+
t_this_stack = t_object . object -> getstack();
11881188

11891189
// Retarget this stack and the target to be relative to the target object
11901190
MCdefaultstackptr = t_this_stack;
@@ -1212,7 +1212,7 @@ void MCEngineExecDispatch(MCExecContext& ctxt, int p_handler_type, MCNameRef p_m
12121212
Boolean olddynamic = MCdynamicpath;
12131213
MCdynamicpath = MCdynamiccard != NULL;
12141214
if (t_stat == ES_PASS || t_stat == ES_NOT_HANDLED)
1215-
switch(t_stat = t_object->handle((Handler_type)p_handler_type, p_message, p_parameters, t_object))
1215+
switch(t_stat = t_object . object -> handle((Handler_type)p_handler_type, p_message, p_parameters, t_object . object))
12161216
{
12171217
case ES_ERROR:
12181218
ctxt . LegacyThrow(EE_DISPATCH_BADCOMMAND, p_message);
@@ -1856,20 +1856,12 @@ void MCEngineEvalMeAsObject(MCExecContext& ctxt, MCObjectPtr& r_object)
18561856
// refers to the derived object context, otherwise it is the object
18571857
// we were compiled in.
18581858

1859-
MCObject *t_object;
1859+
MCObjectPtr t_object;
18601860

18611861
if (ctxt . GetParentScript() == NULL)
1862-
t_object = nil; // destobj!
1862+
r_object . object = nil; // destobj!
18631863
else
1864-
t_object = ctxt . GetObject();
1865-
1866-
r_object . object = t_object;
1867-
r_object . part_id = 0;
1868-
1869-
if (t_object != nil)
1870-
return;
1871-
1872-
// ctxt . LegacyThrow(EE_CHUNK_NOTARGET);
1864+
r_object = ctxt . GetObjectPtr();
18731865
}
18741866

18751867
void MCEngineEvalMenuObjectAsObject(MCExecContext& ctxt, MCObjectPtr& r_object)
@@ -1886,10 +1878,9 @@ void MCEngineEvalMenuObjectAsObject(MCExecContext& ctxt, MCObjectPtr& r_object)
18861878

18871879
void MCEngineEvalTargetAsObject(MCExecContext& ctxt, MCObjectPtr& r_object)
18881880
{
1889-
if (MCtargetptr != nil)
1881+
if (MCtargetptr . object != nil)
18901882
{
1891-
r_object . object = MCtargetptr;
1892-
r_object . part_id = 0;
1883+
r_object = MCtargetptr;
18931884
return;
18941885
}
18951886

engine/src/exec-interface-card.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ void MCCard::GetDefaultButton(MCExecContext& ctxt, MCStringRef& r_button)
277277
return;
278278
else
279279
if (defbutton != nil)
280-
defbutton -> GetLongId(ctxt, r_button);
280+
defbutton -> GetLongId(ctxt, 0, r_button);
281281
else
282-
odefbutton -> GetLongId(ctxt, r_button);
282+
odefbutton -> GetLongId(ctxt, 0, r_button);
283283
}
284284

285285
void MCCard::SetForePixel(MCExecContext& ctxt, uinteger_t* pixel)

engine/src/exec-interface-object.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,20 +1342,20 @@ void MCObject::GetAbbrevId(MCExecContext& ctxt, MCStringRef& r_abbrev_id)
13421342
ctxt . Throw();
13431343
}
13441344

1345-
void MCObject::GetLongName(MCExecContext& ctxt, MCStringRef& r_long_name)
1345+
void MCObject::GetLongName(MCExecContext& ctxt, uint32_t p_part_id, MCStringRef& r_long_name)
13461346
{
13471347
MCAutoValueRef t_long_name;
1348-
if (names(P_LONG_NAME, &t_long_name))
1348+
if (getnameproperty(P_LONG_NAME, p_part_id, &t_long_name))
13491349
if (ctxt.ConvertToString(*t_long_name, r_long_name))
13501350
return;
13511351

13521352
ctxt . Throw();
13531353
}
13541354

1355-
void MCObject::GetLongId(MCExecContext& ctxt, MCStringRef& r_long_id)
1355+
void MCObject::GetLongId(MCExecContext& ctxt, uint32_t p_part_id, MCStringRef& r_long_id)
13561356
{
13571357
MCAutoValueRef t_long_id;
1358-
if (names(P_LONG_ID, &t_long_id))
1358+
if (getnameproperty(P_LONG_ID, p_part_id, &t_long_id))
13591359
if (ctxt.ConvertToString(*t_long_id, r_long_id))
13601360
return;
13611361

@@ -3252,10 +3252,10 @@ void MCObject::GetAbbrevOwner(MCExecContext& ctxt, MCStringRef& r_owner)
32523252
parent -> GetAbbrevName(ctxt, r_owner);
32533253
}
32543254

3255-
void MCObject::GetLongOwner(MCExecContext& ctxt, MCStringRef& r_owner)
3255+
void MCObject::GetLongOwner(MCExecContext& ctxt, uint32_t p_part_id, MCStringRef& r_owner)
32563256
{
32573257
if (parent != nil)
3258-
parent -> GetLongName(ctxt, r_owner);
3258+
parent -> GetLongName(ctxt, p_part_id, r_owner);
32593259
}
32603260

32613261
void MCObject::DoGetProperties(MCExecContext& ctxt, uint32_t part, bool p_effective, MCArrayRef& r_props)

engine/src/exec-interface-stack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ void MCStack::SetIcon(MCExecContext& ctxt, uinteger_t p_id)
10011001
void MCStack::GetOwner(MCExecContext& ctxt, MCStringRef& r_owner)
10021002
{
10031003
if (parent != nil && !MCdispatcher -> ismainstack(this))
1004-
parent -> GetLongId(ctxt, r_owner);
1004+
parent -> GetLongId(ctxt, 0, r_owner);
10051005
}
10061006

10071007
void MCStack::GetMainStack(MCExecContext& ctxt, MCStringRef& r_main_stack)

0 commit comments

Comments
 (0)