File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -354,6 +354,7 @@ def _recentProjectFiles(self):
354354 p = {"path" : p , "thumbnail" : thumbnail }
355355 projects .append (p )
356356 settings .endArray ()
357+ settings .endGroup ()
357358 return projects
358359
359360 @Slot (str )
@@ -393,6 +394,7 @@ def addRecentProjectFile(self, projectFile):
393394 settings .setArrayIndex (i )
394395 settings .setValue ("filepath" , p )
395396 settings .endArray ()
397+ settings .endGroup ()
396398 settings .sync ()
397399
398400 self .recentProjectFilesChanged .emit ()
Original file line number Diff line number Diff line change @@ -76,13 +76,19 @@ ApplicationWindow {
7676
7777 function initFileDialogFolder (dialog , importImages = false ) {
7878 let folder = " "
79- let projects = MeshroomApp .recentProjectFiles
79+ let project = " "
80+ try {
81+ // The list of recent projects might be empty, hence the try/catch
82+ project = MeshroomApp .recentProjectFiles [0 ][" path" ]
83+ } catch (error) {
84+ console .info (" The list of recent projects is currently empty." )
85+ }
8086 let currentItem = mainStack .currentItem
8187
8288 if (currentItem instanceof Homepage) {
8389 // From the homepage, take the folder from the most recent project (no prior check on its existence)
84- if (projects . length > 0 && Filepath .exists (projects[ 0 ][ " path " ] )) {
85- folder = Filepath .stringToUrl (Filepath .dirname (projects[ 0 ][ " path " ] ))
90+ if (project != " " && Filepath .exists (project )) {
91+ folder = Filepath .stringToUrl (Filepath .dirname (project ))
8692 }
8793 } else {
8894
@@ -97,8 +103,8 @@ ApplicationWindow {
97103 } else {
98104 // If the currently opened project has not been saved, the dialog will open in the same
99105 // folder as the most recent project if it exists; otherwise, it will not be set
100- if (projects . length > 0 && Filepath .exists (projects[ 0 ][ " path " ] )) {
101- folder = Filepath .stringToUrl (Filepath .dirname (projects[ 0 ][ " path " ] ))
106+ if (project != " " && Filepath .exists (project )) {
107+ folder = Filepath .stringToUrl (Filepath .dirname (project ))
102108 }
103109 }
104110
You can’t perform that action at this time.
0 commit comments