From 5ebdd5c106e49cdb9aca623863d46dc9e9eab195 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Wed, 20 Apr 2016 10:37:02 +0200 Subject: [PATCH] browser: save/restore rootIndex --- artiq/browser/files.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/artiq/browser/files.py b/artiq/browser/files.py index 3e00e7a6c..38bfec7f3 100644 --- a/artiq/browser/files.py +++ b/artiq/browser/files.py @@ -144,6 +144,8 @@ class FilesDock(QtWidgets.QDockWidget): if not os.path.exists(path): return idx = self.model.index(path) + if not idx.isValid(): + return self.rl.setRootIndex(idx) def scroll_when_loaded(p): @@ -163,12 +165,14 @@ class FilesDock(QtWidgets.QDockWidget): if not os.path.exists(path): return self.select_dir(os.path.dirname(path)) - self.rl.setCurrentIndex(self.model.index(path)) + idx = self.model.index(path) + if not idx.isValid(): + return + self.rl.setCurrentIndex(idx) def save_state(self): return { - "dir": self.model.filePath(self.rt.model().mapToSource( - self.rt.currentIndex())), + "dir": self.model.filePath(self.rl.rootIndex()), "file": self.model.filePath(self.rl.currentIndex()), "header": bytes(self.rt.header().saveState()), "splitter": bytes(self.splitter.saveState()),