MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / restoreExpressions

Method restoreExpressions

Engine/KnobSerialization.cpp:215–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213
214
215void
216KnobSerialization::restoreExpressions(const KnobIPtr & knob,
217 const std::map<std::string, std::string>& oldNewScriptNamesMapping)
218{
219 int dims = std::min( knob->getDimension(), _knob->getDimension() );
220
221 try {
222 for (int i = 0; i < dims; ++i) {
223 if ( !_expressions[i].first.empty() ) {
224 QString expr( QString::fromUtf8( _expressions[i].first.c_str() ) );
225
226 //Replace all occurrences of script-names that we know have changed
227 for (std::map<std::string, std::string>::const_iterator it = oldNewScriptNamesMapping.begin();
228 it != oldNewScriptNamesMapping.end(); ++it) {
229 expr.replace( QString::fromUtf8( it->first.c_str() ), QString::fromUtf8( it->second.c_str() ) );
230 }
231 knob->restoreExpression(i, expr.toStdString(), _expressions[i].second);
232 }
233 }
234 } catch (const std::exception& e) {
235 QString err = QString::fromUtf8("Failed to restore expression: %1").arg( QString::fromUtf8( e.what() ) );
236 appPTR->writeToErrorLog_mt_safe(QString::fromUtf8( knob->getName().c_str() ), QDateTime::currentDateTime(), err);
237 }
238}
239
240void
241KnobSerialization::setChoiceExtraString(const std::string& label)

Callers 2

storeKnobsLinksMethod · 0.80

Calls 8

emptyMethod · 0.80
restoreExpressionMethod · 0.80
toStdStringMethod · 0.80
getNameMethod · 0.80
getDimensionMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected