← Back to team overview

openlp-core team mailing list archive

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

 

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

Requested reviews:
  OpenLP Core (openlp-core)

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

This includes Raoul's code to fix the display area for bug 1041366 but it includes some extra code to prevent the problem with bug 1016843 being reintroduced when OpenLP crashes on Windows when editing a theme whilst many items are in the service.
-- 
https://code.launchpad.net/~j-corwin/openlp/bug-1041366-jc/+merge/121348
Your team OpenLP Core is requested to review the proposed merge of lp:~j-corwin/openlp/bug-1041366-jc into lp:openlp.
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py	2012-08-25 19:23:40 +0000
+++ openlp/core/lib/renderer.py	2012-08-26 22:11:19 +0000
@@ -27,6 +27,7 @@
 ###############################################################################
 
 import logging
+import gc
 
 from PyQt4 import QtGui, QtCore, QtWebKit
 
@@ -96,6 +97,7 @@
             self.display.close()
         self.display = MainDisplay(None, self.image_manager, False, self)
         self.display.setup()
+        #self.web_frame = self.web.page().mainFrame()
         self._theme_dimensions = {}
 
     def update_theme(self, theme_name, old_theme_name=None, only_delete=False):
@@ -221,7 +223,8 @@
         self._set_theme(item_theme_name)
         self.item_theme_name = item_theme_name
 
-    def generate_preview(self, theme_data, force_page=False):
+    def generate_preview(self, theme_data, force_page=False,
+        same_thread=True):
         """
         Generate a preview of a theme.
 
@@ -256,7 +259,15 @@
         if not self.force_page:
             self.display.buildHtml(serviceItem)
             raw_html = serviceItem.get_rendered_frame(0)
-            self.display.text(raw_html)
+            if same_thread:
+                self.display.text(raw_html)
+            else:
+                # This exists for https://bugs.launchpad.net/openlp/+bug/1016843
+                # For unknown reasons if evaluateJavaScript is called
+                # from the themewizard, then it causes a crash on
+                # Windows if there are many items in the service to re-render.
+                # Calling it via a signal seems to workaround the problem.
+                Receiver.send_message(u'renderer_display_text', raw_html)
             preview = self.display.preview()
             return preview
         self.force_page = False
@@ -406,7 +417,15 @@
         if theme_data.font_main_shadow:
             self.page_width -= int(theme_data.font_main_shadow_size)
             self.page_height -= int(theme_data.font_main_shadow_size)
+        # For the life of my I don't know why we have to completely kill the
+        # QWebView in order for the display to work properly, but we do. See
+        # bug #1041366 for an example of what happens if we take this out.
+        self.web = None
+        gc.collect()
+        self.web = QtWebKit.QWebView()
+        self.web.setVisible(False)
         self.web.resize(self.page_width, self.page_height)
+        self.web_frame = self.web.page().mainFrame()
         # Adjust width and height to account for shadow. outline done in css.
         html = u"""<!DOCTYPE html><html><head><script>
             function show_text(newtext) {

=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py	2012-08-09 21:48:05 +0000
+++ openlp/core/ui/maindisplay.py	2012-08-26 22:11:19 +0000
@@ -155,6 +155,9 @@
                 QtCore.SIGNAL(u'update_display_css'), self.cssChanged)
             QtCore.QObject.connect(Receiver.get_receiver(),
                 QtCore.SIGNAL(u'config_updated'), self.configChanged)
+        if parent is None and not self.isLive:
+            QtCore.QObject.connect(Receiver.get_receiver(),
+                QtCore.SIGNAL(u'renderer_display_text'), self.text)
 
     def setTransparency(self, enabled):
         if enabled:

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2012-07-02 18:45:03 +0000
+++ openlp/core/ui/thememanager.py	2012-08-26 22:11:19 +0000
@@ -741,7 +741,7 @@
         """
         log.debug(u'generateImage \n%s ', theme_data)
         return self.mainwindow.renderer.generate_preview(
-            theme_data, forcePage)
+            theme_data, forcePage, False)
 
     def getPreviewImage(self, theme):
         """


Follow ups