Fix crash on non-existing favorites

Corner case when rebuilding favs from scratch
This commit is contained in:
Clement Lefebvre 2019-07-21 16:52:46 +02:00
parent 89f9071bd4
commit 3ad195599b

View File

@ -1223,20 +1223,13 @@ class pluginclass(object):
# For Folders and Network Shares
location = "".join(location.split("%20"))
# TODO: Do we still need this?
#For Special locations
if location == "x-nautilus-desktop:///computer":
location = "/usr/share/applications/nautilus-computer.desktop"
elif location == "x-nautilus-desktop:///home":
location = "/usr/share/applications/nautilus-home.desktop"
elif location == "x-nautilus-desktop:///network":
location = "/usr/share/applications/network-scheme.desktop"
elif location.startswith("x-nautilus-desktop:///"):
location = "/usr/share/applications/nautilus-computer.desktop"
if location.startswith("file://"):
location = location[7:]
if not os.path.exists(location):
print("%s does not exist, skipping." % location)
return None
# Don't add a location twice
for fav in self.favorites:
if fav.type == "location" and fav.desktopFile == location:
@ -1278,6 +1271,7 @@ class pluginclass(object):
position = 0
for app in applicationsList:
try:
app = app.strip()
if app[0:9] == "location:":
@ -1304,6 +1298,9 @@ class pluginclass(object):
favButton.connect("drag-data-get", self.on_drag_data_get)
favButton.connect("drag-data-received", self.on_drag_data_received)
position += 1
except Exception as e:
print("Can't add favorite: %s" % app)
print (e)
self.favoritesSave()
except Exception as e: