fix RecursionError, when opening game settings (closes #2650)

This commit is contained in:
Connectety-T 2020-03-19 00:23:28 +01:00 committed by Mathieu Comandon
parent 10ec196653
commit fd5b697573
2 changed files with 5 additions and 2 deletions

View file

@ -150,7 +150,7 @@ class FileChooserEntry(Gtk.Box):
)
self.pack_end(non_empty_label, False, False, 10)
parent = system.get_existing_parent(path)
if not os.access(parent, os.W_OK):
if parent is not None and not os.access(parent, os.W_OK):
non_writable_destination_label = Gtk.Label(visible=True)
non_writable_destination_label.set_markup(
"<b>Warning</b> The destination folder "

View file

@ -343,7 +343,10 @@ def run_once(function):
def get_existing_parent(path):
"""Return the 1st existing parent for a folder (or itself if the path
exists and is a directory)"""
exists and is a directory). returns None, when none of the parents exists.
"""
if path == "":
return None
if os.path.exists(path) and not os.path.isfile(path):
return path
return get_existing_parent(os.path.dirname(path))