@@ -1088,30 +1088,43 @@ void MCCard::timer(MCNameRef mptr, MCParameter *params)
10881088 MCObject::timer (mptr, params);
10891089}
10901090
1091- Boolean MCCard::del ( )
1091+ bool MCCard::isdeletable ( bool p_check_flag )
10921092{
1093- if (parent == NULL || scriptdepth != 0 || getstack ()->islocked ()
1094- || getstack ()->isediting () || flags & F_C_CANT_DELETE)
1095- {
1096- MCeerror->add (EE_OBJECT_CANTREMOVE, 0 , 0 );
1097- return False;
1098- }
1099- clean ();
1100- if (objptrs != NULL )
1101- {
1102- MCObjptr *optr = objptrs;
1103- do
1104- {
1105- if (optr->getref ()->getscriptdepth () != 0 )
1106- {
1107- MCeerror->add
1108- (EE_OBJECT_CANTREMOVE, 0 , 0 );
1109- return False;
1110- }
1111- optr = optr->next ();
1112- }
1113- while (optr != objptrs);
1114- }
1093+ if (parent == NULL || scriptdepth != 0 ||
1094+ (p_check_flag && getflag (F_C_CANT_DELETE)) ||
1095+ getstack () -> isediting ())
1096+ {
1097+ MCAutoValueRef t_long_name;
1098+ getnameproperty (P_LONG_NAME, 0 , &t_long_name);
1099+ MCeerror->add (EE_OBJECT_CANTREMOVE, 0 , 0 , *t_long_name);
1100+ return false ;
1101+ }
1102+
1103+ if (objptrs != NULL )
1104+ {
1105+ MCObjptr *t_object_ptr = objptrs;
1106+ do
1107+ {
1108+ // if it's a background group then don't check flags
1109+ if (!((t_object_ptr->getref ()->gettype () == CT_GROUP && static_cast <MCGroup *>(t_object_ptr->getref ())->isshared ())) &&
1110+ t_object_ptr->getref ()->isdeletable (true ))
1111+ return false ;
1112+
1113+ t_object_ptr = t_object_ptr->next ();
1114+ }
1115+ while (t_object_ptr != objptrs);
1116+ }
1117+
1118+ return true ;
1119+ }
1120+
1121+ Boolean MCCard::del (bool p_check_flag)
1122+ {
1123+ if (!isdeletable (p_check_flag))
1124+ return False;
1125+
1126+ clean ();
1127+
11151128 MCselected->remove (this );
11161129
11171130 // MW-2008-10-31: [[ ParentScripts ]] Make sure we close the controls
@@ -1151,7 +1164,7 @@ Boolean MCCard::del()
11511164
11521165 // MCObject now does things on del(), so we must make sure we finish by
11531166 // calling its implementation.
1154- return MCObject::del ();
1167+ return MCObject::del (p_check_flag );
11551168}
11561169
11571170struct UpdateDataIdsVisitor : public MCObjectVisitor
0 commit comments