forked from openlp/openlp
stop imageManager thread on shutdown
This commit is contained in:
parent
d2a38f676c
commit
51d69a28ce
@ -167,8 +167,9 @@ class ImageManager(QtCore.QObject):
|
|||||||
self.width = current_screen[u'size'].width()
|
self.width = current_screen[u'size'].width()
|
||||||
self.height = current_screen[u'size'].height()
|
self.height = current_screen[u'size'].height()
|
||||||
self._cache = {}
|
self._cache = {}
|
||||||
self._imageThread = ImageThread(self)
|
self.imageThread = ImageThread(self)
|
||||||
self._conversion_queue = PriorityQueue()
|
self._conversion_queue = PriorityQueue()
|
||||||
|
self.stop_manager = False
|
||||||
QtCore.QObject.connect(Receiver.get_receiver(),
|
QtCore.QObject.connect(Receiver.get_receiver(),
|
||||||
QtCore.SIGNAL(u'config_updated'), self.process_updates)
|
QtCore.SIGNAL(u'config_updated'), self.process_updates)
|
||||||
|
|
||||||
@ -219,8 +220,8 @@ class ImageManager(QtCore.QObject):
|
|||||||
Flush the queue to updated any data to update
|
Flush the queue to updated any data to update
|
||||||
"""
|
"""
|
||||||
# We want only one thread.
|
# We want only one thread.
|
||||||
if not self._imageThread.isRunning():
|
if not self.imageThread.isRunning():
|
||||||
self._imageThread.start()
|
self.imageThread.start()
|
||||||
|
|
||||||
def get_image(self, name):
|
def get_image(self, name):
|
||||||
"""
|
"""
|
||||||
@ -282,15 +283,15 @@ class ImageManager(QtCore.QObject):
|
|||||||
else:
|
else:
|
||||||
log.debug(u'Image in cache %s:%s' % (name, path))
|
log.debug(u'Image in cache %s:%s' % (name, path))
|
||||||
# We want only one thread.
|
# We want only one thread.
|
||||||
if not self._imageThread.isRunning():
|
if not self.imageThread.isRunning():
|
||||||
self._imageThread.start()
|
self.imageThread.start()
|
||||||
|
|
||||||
def _process(self):
|
def _process(self):
|
||||||
"""
|
"""
|
||||||
Controls the processing called from a ``QtCore.QThread``.
|
Controls the processing called from a ``QtCore.QThread``.
|
||||||
"""
|
"""
|
||||||
log.debug(u'_process - started')
|
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()
|
self._process_cache()
|
||||||
log.debug(u'_process - ended')
|
log.debug(u'_process - ended')
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
@ -1134,6 +1135,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
"""
|
"""
|
||||||
# If we just did a settings import, close without saving changes.
|
# If we just did a settings import, close without saving changes.
|
||||||
if self.settingsImported:
|
if self.settingsImported:
|
||||||
|
self.cleanUp(False)
|
||||||
event.accept()
|
event.accept()
|
||||||
if self.serviceManagerContents.isModified():
|
if self.serviceManagerContents.isModified():
|
||||||
ret = self.serviceManagerContents.saveModifiedService()
|
ret = self.serviceManagerContents.saveModifiedService()
|
||||||
@ -1156,8 +1158,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
translate('OpenLP.MainWindow',
|
translate('OpenLP.MainWindow',
|
||||||
'Are you sure you want to close OpenLP?'),
|
'Are you sure you want to close OpenLP?'),
|
||||||
QtGui.QMessageBox.StandardButtons(
|
QtGui.QMessageBox.StandardButtons(
|
||||||
QtGui.QMessageBox.Yes |
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
|
||||||
QtGui.QMessageBox.No),
|
|
||||||
QtGui.QMessageBox.Yes)
|
QtGui.QMessageBox.Yes)
|
||||||
if ret == QtGui.QMessageBox.Yes:
|
if ret == QtGui.QMessageBox.Yes:
|
||||||
self.cleanUp()
|
self.cleanUp()
|
||||||
@ -1168,10 +1169,18 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
|||||||
self.cleanUp()
|
self.cleanUp()
|
||||||
event.accept()
|
event.accept()
|
||||||
|
|
||||||
def cleanUp(self):
|
|
||||||
|
def cleanUp(self, save_settings=True):
|
||||||
"""
|
"""
|
||||||
Runs all the cleanup code before OpenLP shuts down
|
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)
|
||||||
|
if save_settings:
|
||||||
# Clean temporary files used by services
|
# Clean temporary files used by services
|
||||||
self.serviceManagerContents.cleanUp()
|
self.serviceManagerContents.cleanUp()
|
||||||
if QtCore.QSettings().value(u'advanced/save current plugin',
|
if QtCore.QSettings().value(u'advanced/save current plugin',
|
||||||
|
Loading…
Reference in New Issue
Block a user