Prevent Images and Media backgrounds being added when No service Item is present in the live controller.

Fixes: https://launchpad.net/bugs/795980
This commit is contained in:
Tim Bentley 2011-07-03 09:13:48 +01:00
parent 091cdbbc24
commit 2a73f1b188
3 changed files with 19 additions and 5 deletions

View File

@ -233,10 +233,12 @@ class MainDisplay(QtGui.QGraphicsView):
API for replacement backgrounds so Images are added directly to cache API for replacement backgrounds so Images are added directly to cache
""" """
self.image_manager.add_image(name, path) self.image_manager.add_image(name, path)
self.image(name)
if hasattr(self, u'serviceItem'): if hasattr(self, u'serviceItem'):
self.override[u'image'] = name self.override[u'image'] = name
self.override[u'theme'] = self.serviceItem.themedata.theme_name self.override[u'theme'] = self.serviceItem.themedata.theme_name
self.image(name)
return True
return False
def image(self, name): def image(self, name):
""" """
@ -349,6 +351,9 @@ class MainDisplay(QtGui.QGraphicsView):
""" """
Loads and starts a video to run with the option of sound Loads and starts a video to run with the option of sound
""" """
# We request a background video but have no service Item
if isBackground and not hasattr(self, u'serviceItem'):
return None
if not self.mediaObject: if not self.mediaObject:
self.createMediaObject() self.createMediaObject()
log.debug(u'video') log.debug(u'video')

View File

@ -208,8 +208,13 @@ class ImageMediaItem(MediaManagerItem):
filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) filename = unicode(bitem.data(QtCore.Qt.UserRole).toString())
if os.path.exists(filename): if os.path.exists(filename):
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
self.plugin.liveController.display.directImage(name, filename) if self.plugin.liveController.display.directImage(name,
self.resetAction.setVisible(True) filename):
self.resetAction.setVisible(True)
else:
critical_error_message_box(UiStrings().LiveBGError,
translate('ImagePlugin.MediaItem',
'There was no display item to amend.'))
else: else:
critical_error_message_box(UiStrings().LiveBGError, critical_error_message_box(UiStrings().LiveBGError,
unicode(translate('ImagePlugin.MediaItem', unicode(translate('ImagePlugin.MediaItem',

View File

@ -114,8 +114,12 @@ class MediaMediaItem(MediaManagerItem):
filename = unicode(item.data(QtCore.Qt.UserRole).toString()) filename = unicode(item.data(QtCore.Qt.UserRole).toString())
if os.path.exists(filename): if os.path.exists(filename):
(path, name) = os.path.split(filename) (path, name) = os.path.split(filename)
self.plugin.liveController.display.video(filename, 0, True) if self.plugin.liveController.display.video(filename, 0, True):
self.resetAction.setVisible(True) self.resetAction.setVisible(True)
else:
critical_error_message_box(UiStrings().LiveBGError,
translate('MediaPlugin.MediaItem',
'There was no display item to amend.'))
else: else:
critical_error_message_box(UiStrings().LiveBGError, critical_error_message_box(UiStrings().LiveBGError,
unicode(translate('MediaPlugin.MediaItem', unicode(translate('MediaPlugin.MediaItem',