diff --git a/toonz/sources/toonz/subscenecommand.cpp b/toonz/sources/toonz/subscenecommand.cpp index 0e6ae89..3a6c4cc 100644 --- a/toonz/sources/toonz/subscenecommand.cpp +++ b/toonz/sources/toonz/subscenecommand.cpp @@ -1123,9 +1123,16 @@ void bringPegbarsInsideChildXsheet(TXsheet *xsh, TXsheet *childXsh, for (pegbarIt = pegbarIds.begin(); pegbarIt != pegbarIds.end(); ++pegbarIt) { TStageObjectId id = *pegbarIt; TStageObjectParams *data = xsh->getStageObject(id)->getParams(); - childXsh->getStageObject(id)->assignParams(data); + TStageObject *obj = childXsh->getStageObject(id); + obj->assignParams(data); delete data; - childXsh->getStageObject(id)->setParent(xsh->getStageObjectParent(id)); + obj->setParent(xsh->getStageObjectParent(id)); + + // reset grammers of all parameters or they fails to refer to other + // parameters via expression + for (int c = 0; c != TStageObject::T_ChannelCount; ++c) + childXsh->getStageObjectTree()->setGrammar( + obj->getParam((TStageObject::Channel)c)); } } diff --git a/toonz/sources/toonzqt/stageobjectsdata.cpp b/toonz/sources/toonzqt/stageobjectsdata.cpp index b66fbb0..fa5c551 100644 --- a/toonz/sources/toonzqt/stageobjectsdata.cpp +++ b/toonz/sources/toonzqt/stageobjectsdata.cpp @@ -8,6 +8,8 @@ // TnzBase includes #include "tbasefx.h" +#include "tparamcontainer.h" +#include "tparamset.h" // TnzLib includes #include "toonz/tstageobject.h" @@ -116,6 +118,20 @@ bool isColumnSelectionTerminalFx(TFx *fx, TFxSet *terminalFxs, return false; } +//------------------------------------------------------ + +template +void setGrammerToParams(const ParamCont *cont, + const TSyntax::Grammar *grammer) { + for (int p = 0; p != cont->getParamCount(); ++p) { + TParam ¶m = *cont->getParam(p); + if (TDoubleParam *dp = dynamic_cast(¶m)) + dp->setGrammar(grammer); + else if (TParamSet *paramSet = dynamic_cast(¶m)) + setGrammerToParams(paramSet, grammer); + } +} + } // namespace //******************************************************************************** @@ -1167,5 +1183,22 @@ std::vector StageObjectsData::restoreObjects( } } + // reset grammers for all parameters of pasted stage objects and fxs + // or they fails to refer to other parameters via expression + // if they are pasted in different xsheet + TSyntax::Grammar *grammer = xsh->getStageObjectTree()->getGrammar(); + for (auto id : restoredIds) { + TStageObject *obj = xsh->getStageObject(id); + for (int c = 0; c != TStageObject::T_ChannelCount; ++c) + obj->getParam((TStageObject::Channel)c)->setGrammar(grammer); + if (const PlasticSkeletonDeformationP &sd = + obj->getPlasticSkeletonDeformation()) + sd->setGrammar(grammer); + } + std::map::const_iterator it; + for (it = fxTable.begin(); it != fxTable.end(); ++it) { + setGrammerToParams(it->second->getParams(), grammer); + } + return restoredIds; }