Fix hang in powerpointcontroller

This commit is contained in:
Tomas Groth 2018-11-13 22:41:45 +01:00
parent 0271962d6d
commit a1c4374b1d
1 changed files with 10 additions and 1 deletions

View File

@ -337,7 +337,12 @@ class PowerpointDocument(PresentationDocument):
log.debug('main display size: y={y:d}, height={height:d}, '
'x={x:d}, width={width:d}'.format(y=size.y(), height=size.height(),
x=size.x(), width=size.width()))
win32gui.EnumWindows(self._window_enum_callback, size)
try:
win32gui.EnumWindows(self._window_enum_callback, size)
except pywintypes.error:
# When _window_enum_callback returns False to stop the enumeration (looping over open windows)
# it causes an exception that is ignored here
pass
# Make sure powerpoint doesn't steal focus, unless we're on a single screen setup
if len(ScreenList()) > 1:
Registry().get('main_window').activateWindow()
@ -369,6 +374,10 @@ class PowerpointDocument(PresentationDocument):
self.presentation_hwnd = hwnd
# Stop powerpoint from flashing in the taskbar
win32gui.FlashWindowEx(self.presentation_hwnd, win32con.FLASHW_STOP, 0, 0)
# Returning false stops the enumeration (looping over open windows)
return False
else:
return True
def get_slide_number(self):
"""