From f09bfa258d77da720556107c567ebfc682cc3884 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Wed, 20 Apr 2016 10:38:35 +0200 Subject: [PATCH] Revert "browser: simplify and fix state restore" This reverts commit b00089c3d3ffc784940cebb627e5c52f8af7c3ca. --- artiq/browser/files.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/artiq/browser/files.py b/artiq/browser/files.py index 51e034f2c..8fc2467cd 100644 --- a/artiq/browser/files.py +++ b/artiq/browser/files.py @@ -115,9 +115,7 @@ class FilesDock(QtWidgets.QDockWidget): self.datasets.init(rd) def select(self, path): - idx = self.rt_model.index(path) - if not idx.isValid(): - return + idx = self.rt_model.index(os.path.dirname(path)) self.rt.expand(idx) self.rt.scrollTo(idx) self.rt.setCurrentIndex(idx) @@ -131,6 +129,12 @@ class FilesDock(QtWidgets.QDockWidget): } def restore_state(self, state): - self.select(state["selected"]) - self.rt.header().restoreState(QtCore.QByteArray(state["header"])) - self.splitter.restoreState(QtCore.QByteArray(state["splitter"])) + selected = state.get("selected") + if selected: + self.select(selected) + header = state.get("header") + if header: + self.rt.header().restoreState(QtCore.QByteArray(header)) + splitter = state.get("splitter") + if splitter: + self.splitter.restoreState(QtCore.QByteArray(splitter))