diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index b43c491ff..1ad17a039 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -81,9 +81,6 @@ html_expands.append({u'desc':u'Italics', u'start tag':u'{it}', u'start html':u'', u'end tag':u'{/it}', u'end html':u'', u'protected':True}) -# Image image_cache to stop regualar image resizing -image_cache = {} - def translate(context, text, comment=None): """ A special shortcut method to wrap around the Qt4 translation functions. @@ -261,20 +258,14 @@ def resize_image(image, width, height, background=QtCore.Qt.black): return preview preview = preview.scaled(width, height, QtCore.Qt.KeepAspectRatio, QtCore.Qt.SmoothTransformation) - image_cache_key = u'%s%s%s' % (image, unicode(width), unicode(height)) - if image_cache_key in image_cache: - log.debug(u'resize_image - end cache') - return image_cache[image_cache_key] realw = preview.width() realh = preview.height() # and move it to the centre of the preview space new_image = QtGui.QImage(width, height, QtGui.QImage.Format_ARGB32_Premultiplied) - new_image.fill(background) painter = QtGui.QPainter(new_image) + painter.fillRect(new_image.rect(), background) painter.drawImage((width - realw) / 2, (height - realh) / 2, preview) - image_cache[image_cache_key] = new_image - log.debug(u'resize_image - end') return new_image def check_item_selected(list_widget, message): @@ -314,6 +305,7 @@ def expand_tags(text): from spelltextedit import SpellTextEdit from eventreceiver import Receiver +from imagemanager import ImageManager from settingsmanager import SettingsManager from plugin import PluginStatus, StringContent, Plugin from pluginmanager import PluginManager diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 972d849a3..e59a9737b 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -117,6 +117,7 @@ class Manager(object): settings = QtCore.QSettings() settings.beginGroup(plugin_name) self.db_url = u'' + self.is_dirty = False db_type = unicode( settings.value(u'db type', QtCore.QVariant(u'sqlite')).toString()) if db_type == u'sqlite': @@ -150,6 +151,7 @@ class Manager(object): self.session.add(object_instance) if commit: self.session.commit() + self.is_dirty = True return True except InvalidRequestError: self.session.rollback() @@ -220,6 +222,7 @@ class Manager(object): try: self.session.delete(object_instance) self.session.commit() + self.is_dirty = True return True except InvalidRequestError: self.session.rollback() @@ -241,8 +244,17 @@ class Manager(object): query = query.filter(filter_clause) query.delete(synchronize_session=False) self.session.commit() + self.is_dirty = True return True except InvalidRequestError: self.session.rollback() log.exception(u'Failed to delete %s records', object_class.__name__) return False + + def finalise(self): + """ + VACUUM the database on exit. + """ + if self.is_dirty: + engine = create_engine(self.db_url) + engine.execute("vacuum") diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index 511046fe3..dc3a48565 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -90,16 +90,16 @@ body { var transition = %s; function show_video(state, path, volume, loop){ - // Note, the preferred method for looping would be to use the + // Note, the preferred method for looping would be to use the // video tag loop attribute. // But QtWebKit doesn't support this. Neither does it support the // onended event, hence the setInterval() // In addition, setting the currentTime attribute to zero to restart // the video raises an INDEX_SIZE_ERROR: DOM Exception 1 - // To complicate it further, sometimes vid.currentTime stops + // To complicate it further, sometimes vid.currentTime stops // slightly short of vid.duration and vid.ended is intermittent! // - // Note, currently the background may go black between loops. Not + // Note, currently the background may go black between loops. Not // desirable. Need to investigate using two