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

Method loadProject

Engine/Project.cpp:181–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179};
180
181NATRON_NAMESPACE_ANONYMOUS_EXIT
182
183bool
184Project::loadProject(const QString & path,
185 const QString & name,
186 bool isUntitledAutosave,
187 bool attemptToLoadAutosave)
188{
189 reset(false, true);
190
191 try {
192 QString realPath = path;
193 StrUtils::ensureLastPathSeparator(realPath);
194 QString realName = name;
195 bool isAutoSave = isUntitledAutosave;
196 if (!getApp()->isBackground() && !isUntitledAutosave) {
197 // In Gui mode, attempt to load an auto-save for this project if there's one.
198 QString autosaveFileName;
199 bool hasAutoSave = findAutoSaveForProject(realPath, name, &autosaveFileName);
200 if (hasAutoSave) {
201 StandardButtonEnum ret = eStandardButtonNo;
202 if (attemptToLoadAutosave) {
203 QString text = tr("A recent auto-save of %1 was found.\n"
204 "Would you like to use it instead? "
205 "Clicking No will remove this auto-save.").arg(name);
206 ret = Dialogs::questionDialog(tr("Auto-save").toStdString(),
207 text.toStdString(), false, StandardButtons(eStandardButtonYes | eStandardButtonNo),
208 eStandardButtonYes);
209 }
210 if ( (ret == eStandardButtonNo) || (ret == eStandardButtonEscape) ) {
211 QFile::remove(realPath + autosaveFileName);
212 } else {
213 realName = autosaveFileName;
214 isAutoSave = true;
215 {
216 QMutexLocker k(&_imp->projectLock);
217 _imp->lastAutoSaveFilePath = realPath + realName;
218 }
219 }
220 }
221 }
222
223 bool mustSave = false;
224 if ( !loadProjectInternal(realPath, realName, isAutoSave, isUntitledAutosave, &mustSave) ) {
225 appPTR->showErrorLog();
226 } else if (mustSave) {
227 saveProject(realPath, realName, 0);
228 }
229 } catch (const std::exception & e) {
230 Dialogs::errorDialog( tr("Project loader").toStdString(), tr("Error while loading project: %1").arg( QString::fromUtf8( e.what() ) ).toStdString() );
231 if ( !getApp()->isBackground() ) {
232 CreateNodeArgs args(PLUGINID_NATRON_VIEWER, shared_from_this() );
233 args.setProperty<bool>(kCreateNodeArgsPropAutoConnect, false);
234 args.setProperty<bool>(kCreateNodeArgsPropAddUndoRedoCommand, false);
235 getApp()->createNode(args);
236 }
237
238 return false;

Callers 3

knobChangedMethod · 0.45
reloadProjectMethod · 0.45
Sbk_AppFunc_loadProjectFunction · 0.45

Calls 5

getAppFunction · 0.85
toStdStringMethod · 0.80
isBackgroundMethod · 0.45
showErrorLogMethod · 0.45
createNodeMethod · 0.45

Tested by

no test coverage detected