Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

fix expression reference in sub xsheet

shun-iwasawa952984c2751f
diff --git a/toonz/sources/toonz/subscenecommand.cpp b/toonz/sources/toonz/subscenecommand.cpp
index 0e6ae8945..3a6c4ccf1 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 b66fbb0d5..fa5c55124 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 <typename ParamCont>
+void setGrammerToParams(const ParamCont *cont,
+ const TSyntax::Grammar *grammer) {
+ for (int p = 0; p != cont->getParamCount(); ++p) {
+ TParam &param = *cont->getParam(p);
+ if (TDoubleParam *dp = dynamic_cast<TDoubleParam *>(&param))
+ dp->setGrammar(grammer);
+ else if (TParamSet *paramSet = dynamic_cast<TParamSet *>(&param))
+ setGrammerToParams(paramSet, grammer);
+ }
+}
+
} // namespace
//********************************************************************************
@@ -1167,5 +1183,22 @@ std::vector<TStageObjectId> 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<TFx *, TFx *>::const_iterator it;
+ for (it = fxTable.begin(); it != fxTable.end(); ++it) {
+ setGrammerToParams(it->second->getParams(), grammer);
+ }
+
return restoredIds;
}