← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~j-corwin/openlp/bug-927585 into lp:openlp

 

Jonathan Corwin has proposed merging lp:~j-corwin/openlp/bug-927585 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~j-corwin/openlp/bug-927585/+merge/129527

Fix various halts and issues with Presentation plugins

#927585
#936596
#859098
#967061
-- 
https://code.launchpad.net/~j-corwin/openlp/bug-927585/+merge/129527
Your team OpenLP Core is requested to review the proposed merge of lp:~j-corwin/openlp/bug-927585 into lp:openlp.
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py	2012-07-07 14:54:14 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py	2012-10-12 22:18:20 +0000
@@ -155,6 +155,8 @@
             desktop = self.manager.createInstance(u'com.sun.star.frame.Desktop')
         except AttributeError:
             log.warn(u'Failure to find desktop - Impress may have closed')
+        except pywintypes.com_error:
+            log.warn(u'Failure to find desktop - Impress may have closed')
         return desktop if desktop else None
 
     def get_com_servicemanager(self):
@@ -284,6 +286,8 @@
         props = tuple(props)
         doc = self.document
         pages = doc.getDrawPages()
+        if not pages:
+            return
         if not os.path.isdir(self.get_temp_folder()):
             os.makedirs(self.get_temp_folder())
         for idx in range(pages.getCount()):
@@ -359,7 +363,9 @@
         log.debug(u'is active OpenOffice')
         if not self.is_loaded():
             return False
-        return self.control is not None
+        if not self.control:
+            return False
+        return self.control.isRunning()
 
     def unblank_screen(self):
         """
@@ -380,7 +386,7 @@
         Returns true if screen is blank
         """
         log.debug(u'is blank OpenOffice')
-        if self.control:
+        if self.control and self.control.isRunning():
             return self.control.isPaused()
         else:
             return False
@@ -436,7 +442,11 @@
         """
         Triggers the next effect of slide on the running presentation
         """
+        is_paused = self.control.isPaused()
         self.control.gotoNextEffect()
+        time.sleep(0.1)
+        if not is_paused and self.control.isPaused():
+            self.control.gotoPreviousEffect()
 
     def previous_step(self):
         """

=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py	2012-06-30 15:19:33 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py	2012-10-12 22:18:20 +0000
@@ -49,6 +49,7 @@
         """
         self.is_live = live
         self.doc = None
+        self.hide_mode = None
         log.info(u'%s controller loaded' % live)
 
     def add_handler(self, controller, file, hide_mode, slide_no):
@@ -67,6 +68,7 @@
             # Inform slidecontroller that the action failed?
             return
         self.doc.slidenumber = slide_no
+        self.hide_mode = hide_mode
         if self.is_live:
             if hide_mode == HideMode.Screen:
                 Receiver.send_message(u'live_display_hide', HideMode.Screen)
@@ -88,29 +90,40 @@
         Use the last slide number.
         """
         log.debug(u'Live = %s, activate' % self.is_live)
+        if not self.doc:
+            return False
         if self.doc.is_active():
-            return
+            return True
         if not self.doc.is_loaded():
             if not self.doc.load_presentation():
-                return
+                log.warn(u'Failed to activate %s' % self.doc.filepath)
+                return False
         if self.is_live:
             self.doc.start_presentation()
             if self.doc.slidenumber > 1:
                 if self.doc.slidenumber > self.doc.get_slide_count():
                     self.doc.slidenumber = self.doc.get_slide_count()
                 self.doc.goto_slide(self.doc.slidenumber)
+        if self.doc.is_active():
+            return True
+        else:
+            log.warn(u'Failed to activate %s' % self.doc.filepath)
+            return False
 
     def slide(self, slide):
         """
         Go to a specific slide
         """
         log.debug(u'Live = %s, slide' % self.is_live)
+        if not self.doc:
+            return
         if not self.is_live:
             return
-        if self.doc.is_blank():
+        if self.hide_mode:
             self.doc.slidenumber = int(slide) + 1
             return
-        self.activate()
+        if not self.activate():
+            return
         self.doc.goto_slide(int(slide) + 1)
         self.doc.poll_slidenumber(self.is_live)
 
@@ -119,12 +132,15 @@
         Based on the handler passed at startup triggers the first slide
         """
         log.debug(u'Live = %s, first' % self.is_live)
+        if not self.doc:
+            return
         if not self.is_live:
             return
-        if self.doc.is_blank():
+        if self.hide_mode:
             self.doc.slidenumber = 1
             return
-        self.activate()
+        if not self.activate():
+            return
         self.doc.start_presentation()
         self.doc.poll_slidenumber(self.is_live)
 
@@ -133,12 +149,15 @@
         Based on the handler passed at startup triggers the last slide
         """
         log.debug(u'Live = %s, last' % self.is_live)
+        if not self.doc:
+            return
         if not self.is_live:
             return
-        if self.doc.is_blank():
+        if self.hide_mode:
             self.doc.slidenumber = self.doc.get_slide_count()
             return
-        self.activate()
+        if not self.activate():
+            return
         self.doc.goto_slide(self.doc.get_slide_count())
         self.doc.poll_slidenumber(self.is_live)
 
@@ -147,9 +166,11 @@
         Based on the handler passed at startup triggers the next slide event
         """
         log.debug(u'Live = %s, next' % self.is_live)
+        if not self.doc:
+            return
         if not self.is_live:
             return
-        if self.doc.is_blank():
+        if self.hide_mode:
             if self.doc.slidenumber < self.doc.get_slide_count():
                 self.doc.slidenumber = self.doc.slidenumber + 1
             return
@@ -158,7 +179,8 @@
         # contain animations that need to be stepped through.
         if self.doc.slidenumber > self.doc.get_slide_count():
             return
-        self.activate()
+        if not self.activate():
+            return
         self.doc.next_step()
         self.doc.poll_slidenumber(self.is_live)
 
@@ -167,13 +189,16 @@
         Based on the handler passed at startup triggers the previous slide event
         """
         log.debug(u'Live = %s, previous' % self.is_live)
+        if not self.doc:
+            return
         if not self.is_live:
             return
-        if self.doc.is_blank():
+        if self.hide_mode:
             if self.doc.slidenumber > 1:
                 self.doc.slidenumber = self.doc.slidenumber - 1
             return
-        self.activate()
+        if not self.activate():
+            return
         self.doc.previous_step()
         self.doc.poll_slidenumber(self.is_live)
 
@@ -182,6 +207,8 @@
         Based on the handler passed at startup triggers slide show to shut down
         """
         log.debug(u'Live = %s, shutdown' % self.is_live)
+        if not self.doc:
+            return
         self.doc.close_presentation()
         self.doc = None
 
@@ -190,21 +217,30 @@
         Instruct the controller to blank the presentation
         """
         log.debug(u'Live = %s, blank' % self.is_live)
+        self.hide_mode = hide_mode
+        if not self.doc:
+            return
         if not self.is_live:
             return
-        if not self.doc.is_loaded():
-            return
-        if not self.doc.is_active():
-            return
         if hide_mode == HideMode.Theme:
+            if not self.doc.is_loaded():
+                return
+            if not self.doc.is_active():
+                return
             Receiver.send_message(u'live_display_hide', HideMode.Theme)
-        self.doc.blank_screen()
+        elif hide_mode == HideMode.Blank:
+            if not self.activate():
+                return
+            self.doc.blank_screen()
 
     def stop(self):
         """
         Instruct the controller to stop and hide the presentation
         """
         log.debug(u'Live = %s, stop' % self.is_live)
+        self.hide_mode = HideMode.Screen
+        if not self.doc:
+            return
         if not self.is_live:
             return
         if not self.doc.is_loaded():
@@ -218,9 +254,13 @@
         Instruct the controller to unblank the presentation
         """
         log.debug(u'Live = %s, unblank' % self.is_live)
+        self.hide_mode = None
+        if not self.doc:
+            return
         if not self.is_live:
             return
-        self.activate()
+        if not self.activate():
+            return
         if self.doc.slidenumber and \
             self.doc.slidenumber != self.doc.get_slide_number():
             self.doc.goto_slide(self.doc.slidenumber)
@@ -228,6 +268,8 @@
         Receiver.send_message(u'live_display_hide', HideMode.Screen)
 
     def poll(self):
+        if not self.doc:
+            return
         self.doc.poll_slidenumber(self.is_live)
 
 

=== modified file 'openlp/plugins/presentations/lib/powerpointcontroller.py'
--- openlp/plugins/presentations/lib/powerpointcontroller.py	2012-07-07 14:54:14 +0000
+++ openlp/plugins/presentations/lib/powerpointcontroller.py	2012-10-12 22:18:20 +0000
@@ -94,9 +94,9 @@
                 self.docs[0].close_presentation()
             if self.process is None:
                 return
-            if self.process.Presentations.Count > 0:
-                return
             try:
+                if self.process.Presentations.Count > 0:
+                    return
                 self.process.Quit()
             except pywintypes.com_error:
                 pass
@@ -210,6 +210,13 @@
         self.presentation.SlideShowSettings.Run()
         self.presentation.SlideShowWindow.View.State = 1
         self.presentation.SlideShowWindow.Activate()
+        if self.presentation.Application.Version == u'14.0':
+            # Unblanking is broken in PowerPoint 2010, need to redisplay
+            slide = self.presentation.SlideShowWindow.View.CurrentShowPosition
+            click = self.presentation.SlideShowWindow.View.GetClickIndex()
+            self.presentation.SlideShowWindow.View.GotoSlide(slide)
+            if click:
+                self.presentation.SlideShowWindow.View.GotoClick(click)
 
     def blank_screen(self):
         """
@@ -253,6 +260,8 @@
             renderer = self.controller.plugin.renderer
             rect = renderer.screens.current[u'size']
             ppt_window = self.presentation.SlideShowSettings.Run()
+            if not ppt_window:
+                return
             ppt_window.Top = rect.y() * 72 / dpi
             ppt_window.Height = rect.height() * 72 / dpi
             ppt_window.Left = rect.x() * 72 / dpi
@@ -286,6 +295,8 @@
         """
         log.debug(u'next_step')
         self.presentation.SlideShowWindow.View.Next()
+        if self.get_slide_number() > self.get_slide_count():
+            self.previous_step()
 
     def previous_step(self):
         """


Follow ups