| 268 | } |
| 269 | |
| 270 | void |
| 271 | ProjectPrivate::autoSetProjectDirectory(const QString& path) |
| 272 | { |
| 273 | std::string pathCpy = path.toStdString(); |
| 274 | |
| 275 | if ( !pathCpy.empty() && (pathCpy[pathCpy.size() - 1] == '/') ) { |
| 276 | pathCpy.erase(pathCpy.size() - 1, 1); |
| 277 | } |
| 278 | std::string env; |
| 279 | try { |
| 280 | env = envVars->getValue(); |
| 281 | } catch (...) { |
| 282 | // ignore |
| 283 | } |
| 284 | |
| 285 | std::list<std::vector<std::string> > table; |
| 286 | envVars->decodeFromKnobTableFormat(env, &table); |
| 287 | |
| 288 | ///If there was already a OCIO variable, update it, otherwise create it |
| 289 | bool foundProject = false; |
| 290 | for (std::list<std::vector<std::string> >::iterator it = table.begin(); it != table.end(); ++it) { |
| 291 | if ( (*it)[0] == NATRON_PROJECT_ENV_VAR_NAME ) { |
| 292 | (*it)[1] = pathCpy; |
| 293 | foundProject = true; |
| 294 | break; |
| 295 | } |
| 296 | } |
| 297 | if (!foundProject) { |
| 298 | std::vector<std::string> vec(2); |
| 299 | vec[0] = NATRON_PROJECT_ENV_VAR_NAME; |
| 300 | vec[1] = pathCpy; |
| 301 | table.push_back(vec); |
| 302 | } |
| 303 | |
| 304 | |
| 305 | std::string newEnv = envVars->encodeToKnobTableFormat(table); |
| 306 | if (env != newEnv) { |
| 307 | if ( appPTR->getCurrentSettings()->isAutoFixRelativeFilePathEnabled() ) { |
| 308 | _publicInterface->fixRelativeFilePaths(NATRON_PROJECT_ENV_VAR_NAME, pathCpy, false); |
| 309 | } |
| 310 | envVars->setValue(newEnv); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | std::string |
| 315 | ProjectPrivate::runOnProjectSaveCallback(const std::string& filename, |
no test coverage detected