Repository: lutris/lutris

Issue:
Getting a RecursionError on master-branch when opening game config.
**Describe the bug**

When opening game configs of any game installed via a Lutris installer (tested with Battle.net, Epic Games Store and SuperTuxKart), I get a RecursionError. Everything still works as expected, but there is the RecursionError in the output.
I could reproduce this error on another PC which also runs Kubuntu and a friend could reproduce this on Linux Mint (with Battle.net).

**Expected behavior**

Not getting a RecursionError in command-line output.

**Current behavior**

Getting a RecursionError in command-line output. But the config window still opens and everything works as expected.

**Steps to reproduce**

- Start Lutris from the master branch 
- Install a game from the website or via the searchbar, if you haven't already.
- Open the Config of the game (either via right-click or via selecting the game and clicking the wrench in the right sidebar)
- Look at the output.

**Lutris debugging output**
```
INFO     2020-03-12 01:14:00,394 [application.do_command_line:236]:Running Lutris 0.5.4
INFO     2020-03-12 01:14:00,395 [startup.check_driver:62]:Using X.Org
INFO     2020-03-12 01:14:00,395 [startup.check_driver:67]:Running Mesa driver 20.0.1 on Radeon RX 580 Series (POLARIS10, DRM 3.33.0, 5.3.0-40-generic, LLVM 9.0.1) (0x67df)
INFO     2020-03-12 01:14:00,395 [startup.check_driver:79]:GPU: 1002:67DF 148C:2378 using amdgpu drivers
INFO     2020-03-12 01:14:00,430 [startup.check_vulkan:132]:Vulkan is supported
INFO     2020-03-12 01:14:00,431 [dxvk.get_dxvk_versions:21]:Updating DXVK versions
DEBUG    2020-03-12 01:14:00,716 [http.get:65]:GET https://lutris.net/api/runtime
Traceback (most recent call last):
  File "/home/nect/PycharmProjects/lutris/lutris/gui/widgets/common.py", line 152, in on_entry_changed
    parent = system.get_existing_parent(path)
  File "/home/nect/PycharmProjects/lutris/lutris/util/system.py", line 349, in get_existing_parent
    return get_existing_parent(os.path.dirname(path))
  File "/home/nect/PycharmProjects/lutris/lutris/util/system.py", line 349, in get_existing_parent
    return get_existing_parent(os.path.dirname(path))
  File "/home/nect/PycharmProjects/lutris/lutris/util/system.py", line 349, in get_existing_parent
    return get_existing_parent(os.path.dirname(path))
  [Previous line repeated 975 more times]
  File "/home/nect/PycharmProjects/lutris/lutris/util/system.py", line 347, in get_existing_parent
    if os.path.exists(path) and not os.path.isfile(path):
  File "/usr/lib/python3.7/genericpath.py", line 19, in exists
    os.stat(path)
RecursionError: maximum recursion depth exceeded while calling a Python object
DEBUG    2020-03-12 01:14:06,990 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2020-03-12 01:14:07,049 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2020-03-12 01:14:07,069 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
DEBUG    2020-03-12 01:14:07,091 [xrandr._get_vidmodes:16]:Retrieving video modes from XrandR
INFO     2020-03-12 01:14:15,199 [application.do_shutdown:481]:Shutting down Lutris

Process finished with exit code 0
```

**System information**

[lutris-issue-report.zip](https://github.com/lutris/lutris/files/4321706/lutris-issue-report.zip) (zip, because .json alone is not supported by github)





Discussion:
I already have a fix for this (https://github.com/connectety/lutris/tree/fix_recursionerror), but this issue exists for two reasons.

1. I would like someone else to reproduce this, so I am not fixing imaginary bugs.
2. The contributing guidelines say I cannot create features that are not on the roadmap. I would assume its kind of the same for bugs. (but guessing intent was never my strong suit).


Resolving patch:
diff --git a/lutris/gui/widgets/common.py b/lutris/gui/widgets/common.py
--- a/lutris/gui/widgets/common.py
+++ b/lutris/gui/widgets/common.py
@@ -150,7 +150,7 @@ def on_entry_changed(self, widget):
             )
             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 "
diff --git a/lutris/util/system.py b/lutris/util/system.py
--- a/lutris/util/system.py
+++ b/lutris/util/system.py
@@ -343,7 +343,10 @@ def fn_wrapper(*args):
 
 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))


Test patch: