openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #15780
[Merge] lp:~googol/openlp/image-queue into lp:openlp
Andreas Preikschat has proposed merging lp:~googol/openlp/image-queue into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
For more details, see:
https://code.launchpad.net/~googol/openlp/image-queue/+merge/107549
Hello,
- stop the imageManager when closing OpenLP (when you add some images and close OpenLP when in debug mode, you might get a traceback about log being None or the like).
--
https://code.launchpad.net/~googol/openlp/image-queue/+merge/107549
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/imagemanager.py'
--- openlp/core/lib/imagemanager.py 2012-05-20 20:56:11 +0000
+++ openlp/core/lib/imagemanager.py 2012-05-27 11:00:29 +0000
@@ -167,8 +167,9 @@
self.width = current_screen[u'size'].width()
self.height = current_screen[u'size'].height()
self._cache = {}
- self._imageThread = ImageThread(self)
+ self.imageThread = ImageThread(self)
self._conversion_queue = PriorityQueue()
+ self.stop_manager = False
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.process_updates)
@@ -219,8 +220,8 @@
Flush the queue to updated any data to update
"""
# We want only one thread.
- if not self._imageThread.isRunning():
- self._imageThread.start()
+ if not self.imageThread.isRunning():
+ self.imageThread.start()
def get_image(self, name):
"""
@@ -282,15 +283,15 @@
else:
log.debug(u'Image in cache %s:%s' % (name, path))
# We want only one thread.
- if not self._imageThread.isRunning():
- self._imageThread.start()
+ if not self.imageThread.isRunning():
+ self.imageThread.start()
def _process(self):
"""
Controls the processing called from a ``QtCore.QThread``.
"""
log.debug(u'_process - started')
- while not self._conversion_queue.empty():
+ while not self._conversion_queue.empty() and not self.stop_manager:
self._process_cache()
log.debug(u'_process - ended')
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2012-05-26 17:12:01 +0000
+++ openlp/core/ui/mainwindow.py 2012-05-27 11:00:29 +0000
@@ -30,6 +30,7 @@
import sys
import shutil
from tempfile import gettempdir
+import time
from datetime import datetime
from PyQt4 import QtCore, QtGui
@@ -1140,6 +1141,7 @@
return
# If we just did a settings import, close without saving changes.
if self.settingsImported:
+ self.cleanUp(False)
event.accept()
if self.serviceManagerContents.isModified():
ret = self.serviceManagerContents.saveModifiedService()
@@ -1162,8 +1164,7 @@
translate('OpenLP.MainWindow',
'Are you sure you want to close OpenLP?'),
QtGui.QMessageBox.StandardButtons(
- QtGui.QMessageBox.Yes |
- QtGui.QMessageBox.No),
+ QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes)
if ret == QtGui.QMessageBox.Yes:
self.cleanUp()
@@ -1174,21 +1175,29 @@
self.cleanUp()
event.accept()
- def cleanUp(self):
- """
- Runs all the cleanup code before OpenLP shuts down
- """
+ def cleanUp(self, save_settings=True):
+ """
+ Runs all the cleanup code before OpenLP shuts down.
+
+ ``save_settings``
+ Switch to prevent saving settings. Defaults to **True**.
+ """
+ self.imageManager.stop_manager = True
+ while self.imageManager.imageThread.isRunning():
+ time.sleep(0.1)
# Clean temporary files used by services
self.serviceManagerContents.cleanUp()
- if QtCore.QSettings().value(u'advanced/save current plugin',
- QtCore.QVariant(False)).toBool():
- QtCore.QSettings().setValue(u'advanced/current media plugin',
- QtCore.QVariant(self.mediaToolBox.currentIndex()))
+ if save_settings:
+ if QtCore.QSettings().value(u'advanced/save current plugin',
+ QtCore.QVariant(False)).toBool():
+ QtCore.QSettings().setValue(u'advanced/current media plugin',
+ QtCore.QVariant(self.mediaToolBox.currentIndex()))
# Call the cleanup method to shutdown plugins.
log.info(u'cleanup plugins')
self.pluginManager.finalise_plugins()
- # Save settings
- self.saveSettings()
+ if save_settings:
+ # Save settings
+ self.saveSettings()
# Close down the display
if self.liveController.display:
self.liveController.display.close()
Follow ups