From 0a0d3f92ce54145cb44249a40e7b22a52606b2e8 Mon Sep 17 00:00:00 2001 From: Timothy Baldock Date: Sun, 29 Jan 2012 12:50:50 +0000 Subject: [PATCH] Fix infinite loop in file dialog Update gitignore for vi swp files --- .gitignore | 1 + tcui/fileTextBox.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index dde3895..24a6d08 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store *.pyc +*.swp diff --git a/tcui/fileTextBox.py b/tcui/fileTextBox.py index 8929332..1b16ba7 100755 --- a/tcui/fileTextBox.py +++ b/tcui/fileTextBox.py @@ -45,9 +45,14 @@ def filePickerDialog(self, path1, path2=None, dialogText="", dialogFilesAllowed= # If path directory component empty, use passed-in "last" path as starting location # rather than using default starting location + if path1 == u"" and config.last_save_path != u"" and os.path.exists(config.last_save_path): a = config.last_save_path + debug(u"Path a is: %s and path b is: %s" % (a, b)) + + # Check path components exist + # Show the dialog pickerDialog = wx.FileDialog(self.parent, dialogText, a, b, dialogFilesAllowed, dialogFlags) @@ -159,7 +164,11 @@ def existingPath(self, p): if os.path.split(os.path.split(p)[0])[1] != "": p = os.path.split(p)[0] while not os.path.exists(p): + q = p p = os.path.split(p)[0] + # Avoid infinite loop + if p == q: + return u"" return p def comparePaths(self, p1, p2):