fix crash when there isn't any photos on a profile

This commit is contained in:
Romain Bignon 2011-12-12 14:37:24 +01:00
commit 4edeba3d62
2 changed files with 6 additions and 1 deletions

View file

@ -300,10 +300,14 @@ class ContactProfile(QWidget):
logging.warning('Not supported widget: %r' % widget) logging.warning('Not supported widget: %r' % widget)
def previousClicked(self): def previousClicked(self):
if len(self.contact.photos) == 0:
return
self.displayed_photo_idx = (self.displayed_photo_idx - 1) % len(self.contact.photos) self.displayed_photo_idx = (self.displayed_photo_idx - 1) % len(self.contact.photos)
self.display_photo() self.display_photo()
def nextClicked(self): def nextClicked(self):
if len(self.contact.photos) == 0:
return
self.displayed_photo_idx = (self.displayed_photo_idx + 1) % len(self.contact.photos) self.displayed_photo_idx = (self.displayed_photo_idx + 1) % len(self.contact.photos)
self.display_photo() self.display_photo()

View file

@ -230,7 +230,8 @@ class StandardBrowser(mechanize.Browser):
else: else:
return None return None
except (mechanize.BrowserStateError, BrowserRetry): except (mechanize.BrowserStateError, BrowserRetry):
self.home() if hasattr(self, 'home'):
self.home()
return mechanize.Browser.open(self, *args, **kwargs) return mechanize.Browser.open(self, *args, **kwargs)
def get_exception(self, e): def get_exception(self, e):