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

Method loadProjectInternal

Engine/Project.cpp:256–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254} // loadProject
255
256bool
257Project::loadProjectInternal(const QString & path,
258 const QString & name,
259 bool isAutoSave,
260 bool isUntitledAutosave,
261 bool* mustSave)
262{
263 FlagSetter loadingProjectRAII(true, &_imp->isLoadingProject, &_imp->isLoadingProjectMutex);
264 QString filePath = path + name;
265 std::cout << tr("Loading project: %1").arg(filePath).toStdString() << std::endl;
266
267 if ( !QFile::exists(filePath) ) {
268 throw std::invalid_argument( QString( filePath + QString::fromUtf8(" : no such file.") ).toStdString() );
269 }
270
271 bool ret = false;
272 FStreamsSupport::ifstream ifile;
273 FStreamsSupport::open( &ifile, filePath.toStdString() );
274 if (!ifile) {
275 throw std::runtime_error( tr("Failed to open %1").arg(filePath).toStdString() );
276 }
277
278 if ( (NATRON_VERSION_MAJOR == 1) && (NATRON_VERSION_MINOR == 0) && (NATRON_VERSION_REVISION == 0) ) {
279 ///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
280 ///in the BezierCP class serialisation
281 bool foundV = false;
282 QFile f(filePath);
283 f.open(QIODevice::ReadOnly);
284 QTextStream fs(&f);
285 while ( !fs.atEnd() ) {
286 QString line = fs.readLine();
287
288 if ( (line.indexOf( QString::fromUtf8("Natron v1.0.0 RC2") ) != -1) || (line.indexOf( QString::fromUtf8("Natron v1.0.0 RC3") ) != -1) ) {
289 appPTR->setProjectCreatedDuringRC2Or3(true);
290 foundV = true;
291 break;
292 }
293 }
294 if (!foundV) {
295 appPTR->setProjectCreatedDuringRC2Or3(false);
296 }
297 }
298
299 LoadProjectSplashScreen_RAII __raii_splashscreen__(getApp(), name);
300
301 try {
302 bool bgProject;
303 boost::archive::xml_iarchive iArchive(ifile);
304 {
305 FlagSetter __raii_loadingProjectInternal__(true, &_imp->isLoadingProjectInternal, &_imp->isLoadingProjectMutex);
306
307 iArchive >> boost::serialization::make_nvp("Background_project", bgProject);
308 ProjectSerialization projectSerializationObj( getApp() );
309 iArchive >> boost::serialization::make_nvp("Project", projectSerializationObj);
310 ret = load(projectSerializationObj, name, path, mustSave);
311 } // __raii_loadingProjectInternal__
312
313 if (!bgProject) {

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected