| 301 | } |
| 302 | |
| 303 | void |
| 304 | ProjectPrivate::autoSetProjectDirectory(const QString& path) |
| 305 | { |
| 306 | std::string pathCpy = path.toStdString(); |
| 307 | |
| 308 | if ( !pathCpy.empty() && (pathCpy[pathCpy.size() - 1] == '/') ) { |
| 309 | pathCpy.erase(pathCpy.size() - 1, 1); |
| 310 | } |
| 311 | std::string env; |
| 312 | try { |
| 313 | env = envVars->getValue(); |
| 314 | } catch (...) { |
| 315 | // ignore |
| 316 | } |
| 317 | |
| 318 | std::list<std::vector<std::string> > table; |
| 319 | envVars->decodeFromKnobTableFormat(env, &table); |
| 320 | |
| 321 | ///If there was already a OCIO variable, update it, otherwise create it |
| 322 | bool foundProject = false; |
| 323 | for (std::list<std::vector<std::string> >::iterator it = table.begin(); it != table.end(); ++it) { |
| 324 | if ( (*it)[0] == NATRON_PROJECT_ENV_VAR_NAME ) { |
| 325 | (*it)[1] = pathCpy; |
| 326 | foundProject = true; |
| 327 | break; |
| 328 | } |
| 329 | } |
| 330 | if (!foundProject) { |
| 331 | std::vector<std::string> vec(2); |
| 332 | vec[0] = NATRON_PROJECT_ENV_VAR_NAME; |
| 333 | vec[1] = pathCpy; |
| 334 | table.push_back(vec); |
| 335 | } |
| 336 | |
| 337 | |
| 338 | std::string newEnv = envVars->encodeToKnobTableFormat(table); |
| 339 | if (env != newEnv) { |
| 340 | if ( appPTR->getCurrentSettings()->isAutoFixRelativeFilePathEnabled() ) { |
| 341 | _publicInterface->fixRelativeFilePaths(NATRON_PROJECT_ENV_VAR_NAME, pathCpy, false); |
| 342 | } |
| 343 | envVars->setValue(newEnv); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | std::string |
| 348 | ProjectPrivate::runOnProjectSaveCallback(const std::string& filename, |
no test coverage detected