This seems to fix

819271, web NIV download from Bibleserver crash.
No crash (257) and performance jump and reduced memory usage on loading services with huge files.
Fixed filename comparison on drag and drop.

bzr-revno: 1734
This commit is contained in:
Mattias Põldaru 2011-08-30 19:06:45 +01:00 committed by Tim Bentley
commit af10011c0c
7 changed files with 23 additions and 18 deletions

View File

@ -377,7 +377,7 @@ class MediaManagerItem(QtGui.QWidget):
"""
names = []
for count in range(0, self.listView.count()):
names.append(self.listView.item(count).text())
names.append(unicode(self.listView.item(count).text()))
newFiles = []
duplicatesFound = False
for file in files:
@ -396,7 +396,7 @@ class MediaManagerItem(QtGui.QWidget):
critical_error_message_box(
UiStrings().Duplicate,
unicode(translate('OpenLP.MediaManagerItem',
'Duplicate files found on import and ignored.')))
'Duplicate files were found on import and were ignored.')))
def contextMenu(self, point):
item = self.listView.itemAt(point)

View File

@ -586,8 +586,8 @@ class ServiceManager(QtGui.QWidget):
fileTo = None
try:
zip = zipfile.ZipFile(fileName)
for file in zip.namelist():
ucsfile = file_is_unicode(file)
for zipinfo in zip.infolist():
ucsfile = file_is_unicode(zipinfo.filename)
if not ucsfile:
critical_error_message_box(
message=translate('OpenLP.ServiceManager',
@ -595,14 +595,11 @@ class ServiceManager(QtGui.QWidget):
'The content encoding is not UTF-8.'))
continue
osfile = unicode(QtCore.QDir.toNativeSeparators(ucsfile))
filePath = os.path.join(self.servicePath,
os.path.split(osfile)[1])
fileTo = open(filePath, u'wb')
fileTo.write(zip.read(file))
fileTo.flush()
fileTo.close()
if filePath.endswith(u'osd'):
p_file = filePath
filename_only = os.path.split(osfile)[1]
zipinfo.filename = filename_only
zip.extract(zipinfo, self.servicePath)
if filename_only.endswith(u'osd'):
p_file = os.path.join(self.servicePath, filename_only)
if 'p_file' in locals():
Receiver.send_message(u'cursor_busy')
fileTo = open(p_file, u'r')

View File

@ -218,7 +218,7 @@ class BSExtract(object):
send_error_message(u'parse')
return None
content = content.find(u'div').findAll(u'div')
verse_number = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse')
verse_number = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse.*')
verses = {}
for verse in content:
Receiver.send_message(u'openlp_process_events')

View File

@ -184,10 +184,11 @@ class VerseType(object):
verse_index = VerseType.from_translated_string(verse_name)
if verse_index is None:
verse_index = VerseType.from_string(verse_name)
if verse_index is None:
verse_index = VerseType.from_translated_tag(verse_name)
if verse_index is None:
verse_index = VerseType.from_tag(verse_name)
elif len(verse_name) == 1:
if verse_index is None:
verse_index = VerseType.from_translated_tag(verse_name)
if verse_index is None:
verse_index = VerseType.from_tag(verse_name)
return verse_index
def retrieve_windows_encoding(recommendation=None):

View File

@ -190,7 +190,10 @@ class OpenSongImport(SongImport):
# the verse tag
verse_tag = content
verse_num = u'1'
verse_index = VerseType.from_loose_input(verse_tag)
if len(verse_tag) == 0:
verse_index = 0
else:
verse_index = VerseType.from_loose_input(verse_tag)
verse_tag = VerseType.Tags[verse_index]
inst = 1
if [verse_tag, verse_num, inst] in our_verse_order \

View File

@ -103,6 +103,8 @@ class SongShowPlusImport(SongImport):
return
self.import_wizard.progressBar.setMaximum(len(self.import_source))
for file in self.import_source:
if self.stop_import_flag:
return
self.sspVerseOrderList = []
otherCount = 0
otherList = {}

View File

@ -105,6 +105,8 @@ class WowImport(SongImport):
if isinstance(self.import_source, list):
self.import_wizard.progressBar.setMaximum(len(self.import_source))
for file in self.import_source:
if self.stop_import_flag:
return
file_name = os.path.split(file)[1]
# Get the song title
self.title = file_name.rpartition(u'.')[0]