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):
354
354
p = {"path" : p , "thumbnail" : thumbnail }
355
355
projects .append (p )
356
356
settings .endArray ()
357
+ settings .endGroup ()
357
358
return projects
358
359
359
360
@Slot (str )
@@ -393,6 +394,7 @@ def addRecentProjectFile(self, projectFile):
393
394
settings .setArrayIndex (i )
394
395
settings .setValue ("filepath" , p )
395
396
settings .endArray ()
397
+ settings .endGroup ()
396
398
settings .sync ()
397
399
398
400
self .recentProjectFilesChanged .emit ()
Original file line number Diff line number Diff line change @@ -76,13 +76,19 @@ ApplicationWindow {
76
76
77
77
function initFileDialogFolder (dialog , importImages = false ) {
78
78
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
+ }
80
86
let currentItem = mainStack .currentItem
81
87
82
88
if (currentItem instanceof Homepage) {
83
89
// 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 ))
86
92
}
87
93
} else {
88
94
@@ -97,8 +103,8 @@ ApplicationWindow {
97
103
} else {
98
104
// If the currently opened project has not been saved, the dialog will open in the same
99
105
// 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 ))
102
108
}
103
109
}
104
110
You can’t perform that action at this time.
0 commit comments