← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol-hush/openlp/fixes into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol-hush/openlp/fixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  #598393 After adding a new image to a selected (image) item in the service manager it is not selected anymore
  https://bugs.launchpad.net/bugs/598393

For more details, see:
https://code.launchpad.net/~googol-hush/openlp/fixes/+merge/50146

Hello!

I fixed a theme import bug. The problem was, that the theme image could not be generated as the files were still open. Thus attempting to create the thumbnail  causes the error "Corrupt JPEG data: premature end of data segment". (Well, that's my theory.)
The result is, that the images has "grey bars". 

To reproduce you can use this sample theme I created for beta 1: http://ubuntuone.com/p/djX/

Here an image which shows the error and the tiny preview image with its grey bars: http://img577.imageshack.us/i/image1wf.png/

And finally an image of the live screen: http://img267.imageshack.us/i/image2wt.png/
-- 
https://code.launchpad.net/~googol-hush/openlp/fixes/+merge/50146
Your team OpenLP Core is requested to review the proposed merge of lp:~googol-hush/openlp/fixes into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2011-02-10 19:05:35 +0000
+++ openlp/core/lib/__init__.py	2011-02-17 13:12:55 +0000
@@ -239,7 +239,8 @@
     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.

=== modified file 'openlp/core/lib/imagemanager.py'
--- openlp/core/lib/imagemanager.py	2011-02-07 15:55:02 +0000
+++ openlp/core/lib/imagemanager.py	2011-02-17 13:12:55 +0000
@@ -85,8 +85,7 @@
         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 @@
             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))

=== modified file 'openlp/core/lib/rendermanager.py'
--- openlp/core/lib/rendermanager.py	2011-02-11 04:04:05 +0000
+++ openlp/core/lib/rendermanager.py	2011-02-17 13:12:55 +0000
@@ -203,12 +203,12 @@
         # set the default image size for previews
         self.calculate_default(self.screens.preview[u'size'])
         verse = u'The Lord said to {r}Noah{/r}: \n' \
-        'There\'s gonna be a {su}floody{/su}, {sb}floody{/sb}\n' \
-        'The Lord said to {g}Noah{/g}:\n' \
-        'There\'s gonna be a {st}floody{/st}, {it}floody{/it}\n' \
-        'Get those children out of the muddy, muddy \n' \
-        '{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}' \
-        'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n'
+            'There\'s gonna be a {su}floody{/su}, {sb}floody{/sb}\n' \
+            'The Lord said to {g}Noah{/g}:\n' \
+            'There\'s gonna be a {st}floody{/st}, {it}floody{/it}\n' \
+            'Get those children out of the muddy, muddy \n' \
+            '{r}C{/r}{b}h{/b}{bl}i{/bl}{y}l{/y}{g}d{/g}{pk}' \
+            'r{/pk}{o}e{/o}{pp}n{/pp} of the Lord\n'
         # make big page for theme edit dialog to get line count
         if self.force_page:
             verse = verse + verse + verse

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2011-02-15 19:09:07 +0000
+++ openlp/core/ui/thememanager.py	2011-02-17 13:12:55 +0000
@@ -529,6 +529,18 @@
                         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 @@
                     '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):
         """


Follow ups