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

Method runOnProjectLoadCallback

Engine/ProjectPrivate.cpp:477–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475} // ProjectPrivate::runOnProjectCloseCallback
476
477void
478ProjectPrivate::runOnProjectLoadCallback()
479{
480 std::string cb = _publicInterface->getOnProjectLoadCB();
481
482 if ( !cb.empty() ) {
483 std::vector<std::string> args;
484 std::string error;
485 try {
486 NATRON_PYTHON_NAMESPACE::getFunctionArguments(cb, &error, &args);
487 } catch (const std::exception& e) {
488 _publicInterface->getApp()->appendToScriptEditor( std::string("Failed to get signature of onProjectLoaded callback: ")
489 + e.what() );
490
491 return;
492 }
493
494 if ( !error.empty() ) {
495 _publicInterface->getApp()->appendToScriptEditor("Failed to get signature of onProjectLoaded callback: " + error);
496
497 return;
498 }
499
500 std::string signatureError;
501 signatureError.append("The on project loaded callback supports the following signature(s):\n");
502 signatureError.append("- callback(app)");
503 if ( (args.size() != 1) || (args[0] != "app") ) {
504 _publicInterface->getApp()->appendToScriptEditor("Wrong signature of onProjectLoaded callback: " + signatureError);
505
506 return;
507 }
508
509 std::string appID = _publicInterface->getApp()->getAppIDString();
510 std::string script;
511 if (appID != "app") {
512 script = script + "app = " + appID;
513 }
514 script = script + "\n" + cb + "(" + appID + ")\n";
515 std::string err;
516 std::string output;
517 if ( !NATRON_PYTHON_NAMESPACE::interpretPythonScript(script, &err, &output) ) {
518 _publicInterface->getApp()->appendToScriptEditor("Failed to run onProjectLoaded callback: " + err);
519 } else {
520 if ( !output.empty() ) {
521 _publicInterface->getApp()->appendToScriptEditor(output);
522 }
523 }
524 }
525} // ProjectPrivate::runOnProjectLoadCallback
526
527void
528ProjectPrivate::setProjectFilename(const std::string& filename)

Callers 1

loadProjectInternalMethod · 0.80

Calls 7

getOnProjectLoadCBMethod · 0.80
emptyMethod · 0.80
appendMethod · 0.80
getAppIDStringMethod · 0.80
appendToScriptEditorMethod · 0.45
getAppMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected