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

Method loadInternal

Engine/AppInstance.cpp:563–701  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

561}
562
563void
564AppInstance::loadInternal(const CLArgs& cl,
565 bool makeEmptyInstance)
566{
567 try {
568 declareCurrentAppVariable_Python();
569 } catch (const std::exception& e) {
570 throw std::runtime_error( e.what() );
571 }
572
573 if (makeEmptyInstance) {
574 return;
575 }
576
577 executeCommandLinePythonCommands(cl);
578
579 QString exportDocPath = cl.getExportDocsPath();
580 if ( !exportDocPath.isEmpty() ) {
581 exportDocs(exportDocPath);
582
583 return;
584 }
585
586 ///if the app is a background project autorun and the project name is empty just throw an exception.
587 if ( ( (appPTR->getAppType() == AppManager::eAppTypeBackgroundAutoRun) ||
588 ( appPTR->getAppType() == AppManager::eAppTypeBackgroundAutoRunLaunchedFromGui) ) ) {
589 const QString& scriptFilename = cl.getScriptFilename();
590
591 if ( scriptFilename.isEmpty() ) {
592 // cannot start a background process without a file
593 throw std::invalid_argument( tr("Project file name is empty.").toStdString() );
594 }
595
596
597 QFileInfo info(scriptFilename);
598 if ( !info.exists() ) {
599 throw std::invalid_argument( tr("%1: No such file.").arg(scriptFilename).toStdString() );
600 }
601
602 std::list<AppInstance::RenderWork> writersWork;
603
604
605 if ( info.suffix() == QString::fromUtf8(NATRON_PROJECT_FILE_EXT) ) {
606 ///Load the project
607 if ( !_imp->_currentProject->loadProject( info.path(), info.fileName() ) ) {
608 throw std::invalid_argument( tr("Project file loading failed.").toStdString() );
609 }
610 } else if ( info.suffix() == QString::fromUtf8("py") ) {
611 ///Load the python script
612 loadPythonScript(info);
613 } else {
614 throw std::invalid_argument( tr("%1 only accepts python scripts or .ntp project files.").arg( QString::fromUtf8(NATRON_APPLICATION_NAME) ).toStdString() );
615 }
616
617 // exec the python script specified via --onload
618 const QString& extraOnProjectCreatedScript = cl.getDefaultOnProjectLoadedScript();
619 if ( !extraOnProjectCreatedScript.isEmpty() ) {
620 QFileInfo cbInfo(extraOnProjectCreatedScript);

Callers

nothing calls this directly

Calls 15

getAppTypeMethod · 0.80
toStdStringMethod · 0.80
getEffectInstanceMethod · 0.80
emptyMethod · 0.80
isEmptyMethod · 0.45
loadProjectMethod · 0.45
pathMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
isReaderMethod · 0.45
getKnobByNameMethod · 0.45

Tested by

no test coverage detected