Handle Impress errors better

This commit is contained in:
Jon Tibble 2011-02-10 04:19:38 +00:00
parent 0b83c7180f
commit 76fd92b01a

View File

@ -145,7 +145,12 @@ class ImpressController(PresentationController):
log.debug(u'get COM Desktop OpenOffice')
if not self.manager:
return None
return self.manager.createInstance(u'com.sun.star.frame.Desktop')
desktop = None
try:
desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
except AttributeError:
log.exception(u'Failure to find desktop - Impress may have closed')
return desktop if desktop else None
def get_com_servicemanager(self):
"""
@ -166,13 +171,16 @@ class ImpressController(PresentationController):
log.debug(u'Kill OpenOffice')
while self.docs:
self.docs[0].close_presentation()
desktop = None
try:
if os.name != u'nt':
desktop = self.get_uno_desktop()
else:
desktop = self.get_com_desktop()
#Sometimes we get a failure and desktop is None
if not desktop:
except:
log.exception(u'Failed to find an OpenOffice desktop to terminate')
finally:
if not desktop:
return
docs = desktop.getComponents()
if docs.hasElements():