| 213 | |
| 214 | |
| 215 | void |
| 216 | KnobSerialization::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 | |
| 240 | void |
| 241 | KnobSerialization::setChoiceExtraString(const std::string& label) |
no test coverage detected