Two fixes for errors on service file handling plus one bug fix.

bzr-revno: 1440
This commit is contained in:
Mattias Põldaru 2011-03-31 13:36:36 +02:00 committed by Raoul Snyman
commit 15f163cebd
2 changed files with 17 additions and 0 deletions

View File

@ -588,6 +588,21 @@ class ServiceManager(QtGui.QWidget):
message=translate('OpenLP.ServiceManager',
'File could not be opened because it is corrupt.'))
log.exception(u'Problem loading service file %s' % fileName)
except zipfile.BadZipfile:
if os.path.getsize(fileName) == 0:
log.exception(u'Service file is zero sized: %s' % fileName)
QtGui.QMessageBox.information(self,
translate('OpenLP.ServiceManager', 'Empty File'),
translate('OpenLP.ServiceManager', 'This service file '
'does not contain any data.'))
else:
log.exception(u'Service file is cannot be extracted as zip: '
u'%s' % fileName)
QtGui.QMessageBox.information(self,
translate('OpenLP.ServiceManager', 'Corrupt File'),
translate('OpenLP.ServiceManager', 'This file is either'
'corrupt or not an OpenLP 2.0 service file.'))
return
finally:
if fileTo:
fileTo.close()

View File

@ -269,6 +269,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if index is None:
index = VerseType.Other
verse[0][u'type'] = VerseType.Tags[index]
if verse[0][u'label'] == u'':
verse[0][u'label'] = u'1'
verse_def = u'%s%s' % (verse[0][u'type'], verse[0][u'label'])
item = QtGui.QTableWidgetItem(verse[1])
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def))