changeset 625:5646ecd3e35e

core: fixed crash on first run, when no profile exist yet fix bug 24
author Goffi <goffi@goffi.org>
date Thu, 20 Jun 2013 17:22:40 +0200
parents 70988f08d0ad
children 190ccc6dc36c
files src/memory/memory.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/memory/memory.py	Thu Jun 20 17:17:35 2013 +0200
+++ b/src/memory/memory.py	Thu Jun 20 17:22:40 2013 +0200
@@ -189,7 +189,11 @@
             default = self.host.memory.memory_data.get('Profile_default')
             if not default:
                 info(_('No default profile, returning first one'))  # TODO: manage real default profile
-                default = self.host.memory.memory_data['Profile_default'] = self.storage.getProfilesList()[0]
+                try:
+                    default = self.host.memory.memory_data['Profile_default'] = self.storage.getProfilesList()[0]
+                except IndexError:
+                    info(_('No profile exist yet'))
+                    return ""
             return default  # FIXME: temporary, must use real default value, and fallback to first one if it doesn't exists
         if not self.storage.hasProfile(profile_key):
             info(_('Trying to access an unknown profile'))