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

Method loadProjectInternal

Engine/Project.cpp:274–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272} // loadProject
273
274bool
275Project::loadProjectInternal(const QString & path,
276 const QString & name,
277 bool isAutoSave,
278 bool isUntitledAutosave,
279 bool* mustSave)
280{
281 FlagSetter loadingProjectRAII(true, &_imp->isLoadingProject, &_imp->isLoadingProjectMutex);
282 QString filePath = path + name;
283 std::cout << tr("Loading project: %1").arg(filePath).toStdString() << std::endl;
284
285 if ( !QFile::exists(filePath) ) {
286 throw std::invalid_argument( QString( filePath + QString::fromUtf8(" : no such file.") ).toStdString() );
287 }
288
289 bool ret = false;
290 FStreamsSupport::ifstream ifile;
291 FStreamsSupport::open( &ifile, filePath.toStdString() );
292 if (!ifile) {
293 throw std::runtime_error( tr("Failed to open %1").arg(filePath).toStdString() );
294 }
295
296 if ( (NATRON_VERSION_MAJOR == 1) && (NATRON_VERSION_MINOR == 0) && (NATRON_VERSION_REVISION == 0) ) {
297 ///Try to determine if the project was made during Natron v1.0.0 - RC2 or RC3 to detect a bug we introduced at that time
298 ///in the BezierCP class serialisation
299 bool foundV = false;
300 QFile f(filePath);
301 f.open(QIODevice::ReadOnly);
302 QTextStream fs(&f);
303 while ( !fs.atEnd() ) {
304 QString line = fs.readLine();
305
306 if ( (line.indexOf( QString::fromUtf8("Natron v1.0.0 RC2") ) != -1) || (line.indexOf( QString::fromUtf8("Natron v1.0.0 RC3") ) != -1) ) {
307 appPTR->setProjectCreatedDuringRC2Or3(true);
308 foundV = true;
309 break;
310 }
311 }
312 if (!foundV) {
313 appPTR->setProjectCreatedDuringRC2Or3(false);
314 }
315 }
316
317 LoadProjectSplashScreen_RAII __raii_splashscreen__(getApp(), name);
318
319 try {
320 bool bgProject;
321 boost::archive::xml_iarchive iArchive(ifile);
322 {
323 FlagSetter __raii_loadingProjectInternal__(true, &_imp->isLoadingProjectInternal, &_imp->isLoadingProjectMutex);
324
325 iArchive >> boost::serialization::make_nvp("Background_project", bgProject);
326 ProjectSerialization projectSerializationObj( getApp() );
327 iArchive >> boost::serialization::make_nvp("Project", projectSerializationObj);
328 ret = load(projectSerializationObj, name, path, mustSave);
329 } // __raii_loadingProjectInternal__
330
331 if (!bgProject) {

Callers

nothing calls this directly

Calls 15

openFunction · 0.85
getAppFunction · 0.85
QDateTimeClass · 0.85
toStdStringMethod · 0.80
setProjectFilenameMethod · 0.80
setProjectPathMethod · 0.80
QStringClass · 0.70
loadFunction · 0.70
openMethod · 0.45

Tested by

no test coverage detected