mirror of https://gitlab.com/openlp/openlp.git
Merge branch 'issue-1200' into 'master'
Silence any errors from the LibreOffice shutdown on macOS Closes #1200 See merge request openlp/openlp!505
This commit is contained in:
commit
ef1e5685b2
|
@ -180,23 +180,24 @@ class LibreOfficeServer(object):
|
||||||
if hasattr(self, '_docs'):
|
if hasattr(self, '_docs'):
|
||||||
while self._docs:
|
while self._docs:
|
||||||
self._docs[0].close_presentation()
|
self._docs[0].close_presentation()
|
||||||
docs = self.desktop.getComponents()
|
if self.desktop:
|
||||||
count = 0
|
docs = self.desktop.getComponents()
|
||||||
if docs.hasElements():
|
count = 0
|
||||||
list_elements = docs.createEnumeration()
|
if docs.hasElements():
|
||||||
while list_elements.hasMoreElements():
|
list_elements = docs.createEnumeration()
|
||||||
doc = list_elements.nextElement()
|
while list_elements.hasMoreElements():
|
||||||
if doc.getImplementationName() != 'com.sun.star.comp.framework.BackingComp':
|
doc = list_elements.nextElement()
|
||||||
count += 1
|
if doc.getImplementationName() != 'com.sun.star.comp.framework.BackingComp':
|
||||||
if count > 0:
|
count += 1
|
||||||
log.debug('LibreOffice not terminated as docs are still open')
|
if count > 0:
|
||||||
can_kill = False
|
log.debug('LibreOffice not terminated as docs are still open')
|
||||||
else:
|
can_kill = False
|
||||||
try:
|
else:
|
||||||
self.desktop.terminate()
|
try:
|
||||||
log.debug('LibreOffice killed')
|
self.desktop.terminate()
|
||||||
except Exception:
|
log.debug('LibreOffice killed')
|
||||||
log.exception('Failed to terminate LibreOffice')
|
except Exception:
|
||||||
|
log.exception('Failed to terminate LibreOffice')
|
||||||
if getattr(self, '_process') and can_kill:
|
if getattr(self, '_process') and can_kill:
|
||||||
self._process.kill()
|
self._process.kill()
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,12 @@ class MacLOController(PresentationController, LogMixin):
|
||||||
Called at system exit to clean up any running presentations.
|
Called at system exit to clean up any running presentations.
|
||||||
"""
|
"""
|
||||||
log.debug('Kill LibreOffice')
|
log.debug('Kill LibreOffice')
|
||||||
self.client.shutdown()
|
try:
|
||||||
|
# Some people like to close LibreOffice themselves, let's just catch any errors so that OpenLP fails
|
||||||
|
# silently
|
||||||
|
self.client.shutdown()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
self.server_process.kill()
|
self.server_process.kill()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,23 @@ class TestMacLOController(TestCase, TestMixin):
|
||||||
controller._client.shutdown.assert_called_once_with()
|
controller._client.shutdown.assert_called_once_with()
|
||||||
controller.server_process.kill.assert_called_once_with()
|
controller.server_process.kill.assert_called_once_with()
|
||||||
|
|
||||||
|
@patch('openlp.plugins.presentations.lib.maclocontroller.MacLOController._start_server')
|
||||||
|
def test_kill_client_already_closed(self, mocked_start_server):
|
||||||
|
"""
|
||||||
|
Test the kill() method when the client is already closed
|
||||||
|
"""
|
||||||
|
# GIVEN: A controller and a client
|
||||||
|
controller = MacLOController(plugin=self.mock_plugin)
|
||||||
|
controller._client = MagicMock(**{'shutdown.side_effect': Exception})
|
||||||
|
controller.server_process = MagicMock()
|
||||||
|
|
||||||
|
# WHEN: start_process() is called
|
||||||
|
controller.kill()
|
||||||
|
|
||||||
|
# THEN: The client's start_process() should have been called
|
||||||
|
controller._client.shutdown.assert_called_once_with()
|
||||||
|
controller.server_process.kill.assert_called_once_with()
|
||||||
|
|
||||||
|
|
||||||
class TestMacLODocument(TestCase):
|
class TestMacLODocument(TestCase):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue