From 2d447a05da2b53bcb7b419acb93f817e93105c73 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 31 Mar 2016 02:44:10 +0200 Subject: [PATCH] GTK: improve error handling in refreshView' This could theoretically lead to infinite recursion, but only in case "/" is inaccessible or something. In which case the user has really bigger problems. --- src/HSFM/GUI/Gtk/MyView.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/HSFM/GUI/Gtk/MyView.hs b/src/HSFM/GUI/Gtk/MyView.hs index 2a25271..fff613a 100644 --- a/src/HSFM/GUI/Gtk/MyView.hs +++ b/src/HSFM/GUI/Gtk/MyView.hs @@ -201,6 +201,12 @@ createTreeView = do -- |Re-reads the current directory or the given one and updates the View. +-- +-- If the third argument is Nothing, it tries to re-read the current directory. +-- If that fails, it reads "/" instead. +-- +-- If the third argument is (Just path) it tries to read "path". If that +-- fails, it tread "/" instead. refreshView :: MyGUI -> MyView -> Maybe FilePath @@ -230,6 +236,9 @@ refreshView mygui myview mfp = -- |Refreshes the View based on the given directory. +-- +-- If the directory is not a Dir or a Symlink pointing to a Dir, then +-- calls `refreshView` with the 3rd argument being Nothing. refreshView' :: MyGUI -> MyView -> AnchoredFile FileInfo @@ -254,6 +263,7 @@ refreshView' mygui myview dt@(ADirOrSym _) = do ntps <- mapM treeRowReferenceGetPath trs mapM_ (treeSelectionSelectPath tvs) ntps _ -> return () +refreshView' mygui myview (_ :/ Failed{}) = refreshView mygui myview Nothing refreshView' _ _ _ = return ()