Skip to content

Commit 9af6ade

Browse files
committed
[qt6][ui] Limit useless calls to recentProjectFiles when opening dialogs
This prevents emitting signals that lead to countless updates when a single one is necessary, thus causing some freezes in the interface.
1 parent d63f7f2 commit 9af6ade

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

meshroom/ui/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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()

meshroom/ui/qml/main.qml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)