fixed bug 802150 (Attempt to save a service causes a crash when image/media/presentation files do not exist)

bzr-revno: 1707
Fixes: https://launchpad.net/bugs/802150
This commit is contained in:
Stevan Pettit 2011-08-11 11:20:29 +02:00 committed by Andreas Preikschat
commit f92552735f

View File

@ -487,6 +487,7 @@ class ServiceManager(QtGui.QWidget):
item[u'service_item'].get_service_repr()}) item[u'service_item'].get_service_repr()})
if not item[u'service_item'].uses_file(): if not item[u'service_item'].uses_file():
continue continue
skipMissing = False
for frame in item[u'service_item'].get_frames(): for frame in item[u'service_item'].get_frames():
if item[u'service_item'].is_image(): if item[u'service_item'].is_image():
path_from = frame[u'path'] path_from = frame[u'path']
@ -495,25 +496,29 @@ class ServiceManager(QtGui.QWidget):
# Only write a file once # Only write a file once
if path_from in write_list: if path_from in write_list:
continue continue
file_size = os.path.getsize(path_from) if not os.path.exists(path_from):
size_limit = 52428800 # 50MiB if not skipMissing:
#if file_size > size_limit: Receiver.send_message(u'cursor_normal')
# # File exeeds size_limit bytes, ask user title = unicode(translate('OpenLP.ServiceManager',
# message = unicode(translate('OpenLP.ServiceManager', 'Service File Missing'))
# 'Do you want to include \n%.1f MB file "%s"\n' message = unicode(translate('OpenLP.ServiceManager',
# 'into the service file?\nThis may take some time.\n\n' 'File missing from service\n\n %s \n\n'
# 'Please note that you need to\ntake care of that file' 'Continue saving?' % path_from ))
# ' yourself,\nif you leave it out.')) % \ answer = QtGui.QMessageBox.critical(self, title,
# (file_size/1048576, os.path.split(path_from)[1]) message,
# ans = QtGui.QMessageBox.question(self.mainwindow, QtGui.QMessageBox.StandardButtons(
# translate('OpenLP.ServiceManager', 'Including Large ' QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
# 'File'), message, QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.YesToAll))
# QtGui.QMessageBox.Ok|QtGui.QMessageBox.Cancel), if answer == QtGui.QMessageBox.No:
# QtGui.QMessageBox.Ok) self.mainwindow.finishedProgressBar()
# if ans == QtGui.QMessageBox.Cancel: return False
# continue if answer == QtGui.QMessageBox.YesToAll:
write_list.append(path_from) skipMissing = True
total_size += file_size Receiver.send_message(u'cursor_busy')
else:
file_size = os.path.getsize(path_from)
write_list.append(path_from)
total_size += file_size
log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' % log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' %
total_size) total_size)
service_content = cPickle.dumps(service) service_content = cPickle.dumps(service)