MCPcopy Create free account
hub / github.com/MrKepzie/Natron / autoSetProjectDirectory

Method autoSetProjectDirectory

Engine/ProjectPrivate.cpp:270–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void
271ProjectPrivate::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
314std::string
315ProjectPrivate::runOnProjectSaveCallback(const std::string& filename,

Callers 1

saveProjectInternalMethod · 0.80

Calls 14

toStdStringMethod · 0.80
emptyMethod · 0.80
getCurrentSettingsMethod · 0.80
fixRelativeFilePathsMethod · 0.80
sizeMethod · 0.45
eraseMethod · 0.45
getValueMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected