forked from openlp/openlp
Fix the error 'Corrupt JPEG data: premature end of data segment'
bzr-revno: 1307
This commit is contained in:
commit
bb3ee202db
@ -239,7 +239,8 @@ def resize_image(image, width, height, background=QtCore.Qt.black):
|
||||
Resize an image to fit on the current screen.
|
||||
|
||||
``image``
|
||||
The image to resize.
|
||||
The image to resize. It has to be either a ``QImage`` instance or the
|
||||
path to the image.
|
||||
|
||||
``width``
|
||||
The new image width.
|
||||
|
@ -85,8 +85,7 @@ class ImageManager(QtCore.QObject):
|
||||
for key in self._cache.keys():
|
||||
image = self._cache[key]
|
||||
image.dirty = True
|
||||
image.image = resize_image(image.path,
|
||||
self.width, self.height)
|
||||
image.image = resize_image(image.path, self.width, self.height)
|
||||
self._cache_dirty = True
|
||||
# only one thread please
|
||||
if not self._thread_running:
|
||||
@ -128,8 +127,7 @@ class ImageManager(QtCore.QObject):
|
||||
image = Image()
|
||||
image.name = name
|
||||
image.path = path
|
||||
image.image = resize_image(path,
|
||||
self.width, self.height)
|
||||
image.image = resize_image(path, self.width, self.height)
|
||||
self._cache[name] = image
|
||||
else:
|
||||
log.debug(u'Image in cache %s:%s' % (name, path))
|
||||
|
@ -529,6 +529,18 @@ class ThemeManager(QtGui.QWidget):
|
||||
else:
|
||||
outfile = open(fullpath, u'wb')
|
||||
outfile.write(zip.read(file))
|
||||
except (IOError, NameError):
|
||||
critical_error_message_box(
|
||||
translate('OpenLP.ThemeManager', 'Validation Error'),
|
||||
translate('OpenLP.ThemeManager', 'File is not a valid theme.'))
|
||||
log.exception(u'Importing theme from zip failed %s' % filename)
|
||||
finally:
|
||||
# Close the files, to be able to continue creating the theme.
|
||||
if zip:
|
||||
zip.close()
|
||||
if outfile:
|
||||
outfile.close()
|
||||
# As all files are closed, we can create the Theme.
|
||||
if filexml:
|
||||
theme = self._createThemeFromXml(filexml, self.path)
|
||||
self.generateAndSaveImage(dir, themename, theme)
|
||||
@ -539,17 +551,6 @@ class ThemeManager(QtGui.QWidget):
|
||||
'File is not a valid theme.'))
|
||||
log.exception(u'Theme file does not contain XML data %s' %
|
||||
filename)
|
||||
except (IOError, NameError):
|
||||
critical_error_message_box(
|
||||
translate('OpenLP.ThemeManager', 'Validation Error'),
|
||||
translate('OpenLP.ThemeManager',
|
||||
'File is not a valid theme.'))
|
||||
log.exception(u'Importing theme from zip failed %s' % filename)
|
||||
finally:
|
||||
if zip:
|
||||
zip.close()
|
||||
if outfile:
|
||||
outfile.close()
|
||||
|
||||
def checkIfThemeExists(self, themeName):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user