From 9fa14f3e3ab9ebcef372fd51d09994874634b369 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 20 May 2012 17:52:21 +0200 Subject: [PATCH 1/4] attempt to fix bug 923496 Fixes: https://launchpad.net/bugs/923496 --- openlp/core/__init__.py | 3 ++- openlp/core/ui/mainwindow.py | 18 +++++++++++++----- openlp/core/ui/slidecontroller.py | 4 ++-- openlp/core/utils/__init__.py | 3 +-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 71c27a1d0..c26757535 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -127,7 +127,7 @@ class OpenLP(QtGui.QApplication): # make sure Qt really display the splash screen self.processEvents() # start the main app window - self.mainWindow = MainWindow(self.clipboard(), self.args) + self.mainWindow = MainWindow(self) self.mainWindow.show() if show_splash: # now kill the splashscreen @@ -146,6 +146,7 @@ class OpenLP(QtGui.QApplication): Receiver.send_message(u'live_display_blank_check') self.mainWindow.appStartup() # Skip exec_() for gui tests + self.eventLoopIsActive = True if not testing: return self.exec_() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index e4a4e1616..8e9d2be88 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -542,14 +542,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ log.info(u'MainWindow loaded') - def __init__(self, clipboard, arguments): + def __init__(self, parent): """ This constructor sets up the interface, the various managers, and the plugins. """ QtGui.QMainWindow.__init__(self) - self.clipboard = clipboard - self.arguments = arguments + self.parent = lambda: parent + self.clipboard = self.parent().clipboard() + self.arguments = self.parent().args # Set up settings sections for the main application # (not for use by plugins) self.uiSettingsSection = u'user interface' @@ -830,7 +831,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): translate('OpenLP.MainWindow', 'OpenLP Main Display Blanked'), translate('OpenLP.MainWindow', - 'The Main Display has been blanked out')) + 'The Main Display has been blanked out')) def onErrorMessage(self, data): Receiver.send_message(u'close_splash') @@ -1132,6 +1133,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ Hook to close the main window and display windows on exit """ + # The MainApplication did not even enter the event loop (this happens + # when OpenLP is not fully loaded). Just ignore the event. + if not hasattr(self.parent(), u'eventLoopIsActive'): + event.ignore() + return # If we just did a settings import, close without saving changes. if self.settingsImported: event.accept() @@ -1184,7 +1190,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): # Save settings self.saveSettings() # Close down the display - self.liveController.display.close() + if self.liveController.display: + self.liveController.display.close() + self.liveController.display = None def serviceChanged(self, reset=False, serviceName=None): """ diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 1dc005aa6..66e0c6515 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -73,6 +73,7 @@ class Controller(QtGui.QWidget): controller = self Receiver.send_message('%s' % sender, [controller, args]) + class SlideController(Controller): """ SlideController is the slide controller widget. This widget is what the @@ -577,8 +578,7 @@ class SlideController(Controller): # rebuild display as screen size changed if self.display: self.display.close() - self.display = MainDisplay(self, self.imageManager, self.isLive, - self) + self.display = MainDisplay(self, self.imageManager, self.isLive, self) self.display.setup() if self.isLive: self.__addActionsToWidget(self.display) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 9d00e22b7..f73237c06 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -34,7 +34,6 @@ import os import re from subprocess import Popen, PIPE import sys -import time import urllib2 from PyQt4 import QtGui, QtCore @@ -69,7 +68,7 @@ class VersionThread(QtCore.QThread): """ Run the thread. """ - time.sleep(1) + self.sleep(1) app_version = get_application_version() version = check_latest_version(app_version) if LooseVersion(str(version)) > LooseVersion(str(app_version[u'full'])): From 45c05e700d8ca0707ae40ec8db9e5c148b9f8749 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 23 May 2012 18:53:04 +0200 Subject: [PATCH 2/4] clean ups --- openlp/core/__init__.py | 3 ++- openlp/core/ui/mainwindow.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py index 88f31b2ad..96520195d 100644 --- a/openlp/core/__init__.py +++ b/openlp/core/__init__.py @@ -91,6 +91,7 @@ class OpenLP(QtGui.QApplication): """ Override exec method to allow the shared memory to be released on exit """ + self.eventLoopIsActive = True QtGui.QApplication.exec_() self.sharedMemory.detach() @@ -98,6 +99,7 @@ class OpenLP(QtGui.QApplication): """ Run the OpenLP application. """ + self.eventLoopIsActive = False # On Windows, the args passed into the constructor are # ignored. Not very handy, so set the ones we want to use. self.args.extend(args) @@ -146,7 +148,6 @@ class OpenLP(QtGui.QApplication): Receiver.send_message(u'live_display_blank_check') self.mainWindow.appStartup() # Skip exec_() for gui tests - self.eventLoopIsActive = True if not testing: return self.exec_() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 3b26820e9..6deb769af 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -549,8 +549,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ QtGui.QMainWindow.__init__(self) self.parent = lambda: parent - self.clipboard = self.parent().clipboard() - self.arguments = self.parent().args + self.clipboard = self.mainwindow().clipboard() + self.arguments = self.mainwindow().args # Set up settings sections for the main application # (not for use by plugins) self.uiSettingsSection = u'user interface' @@ -1135,7 +1135,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ # The MainApplication did not even enter the event loop (this happens # when OpenLP is not fully loaded). Just ignore the event. - if not hasattr(self.parent(), u'eventLoopIsActive'): + if not self.mainwindow().eventLoopIsActive: event.ignore() return # If we just did a settings import, close without saving changes. From 0517f3d8d7ca87868648343aa71f8eaad29a6211 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 23 May 2012 18:59:28 +0200 Subject: [PATCH 3/4] renamed attribute --- openlp/core/ui/mainwindow.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 6deb769af..20a2551d0 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -542,15 +542,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ log.info(u'MainWindow loaded') - def __init__(self, parent): + def __init__(self, application): """ This constructor sets up the interface, the various managers, and the plugins. """ QtGui.QMainWindow.__init__(self) - self.parent = lambda: parent - self.clipboard = self.mainwindow().clipboard() - self.arguments = self.mainwindow().args + self.application = lambda: application + self.clipboard = self.application().clipboard() + self.arguments = self.application().args # Set up settings sections for the main application # (not for use by plugins) self.uiSettingsSection = u'user interface' @@ -1135,7 +1135,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ # The MainApplication did not even enter the event loop (this happens # when OpenLP is not fully loaded). Just ignore the event. - if not self.mainwindow().eventLoopIsActive: + if not self.application().eventLoopIsActive: event.ignore() return # If we just did a settings import, close without saving changes. From 56b02b02b1ba4fd2b03e52e3c0f4765837c6f836 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 26 May 2012 19:12:01 +0200 Subject: [PATCH 4/4] attribute instead of method --- openlp/core/ui/mainwindow.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 20a2551d0..fe0d69c32 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -548,9 +548,9 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): plugins. """ QtGui.QMainWindow.__init__(self) - self.application = lambda: application - self.clipboard = self.application().clipboard() - self.arguments = self.application().args + self.application = application + self.clipboard = self.application.clipboard() + self.arguments = self.application.args # Set up settings sections for the main application # (not for use by plugins) self.uiSettingsSection = u'user interface' @@ -1135,7 +1135,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): """ # The MainApplication did not even enter the event loop (this happens # when OpenLP is not fully loaded). Just ignore the event. - if not self.application().eventLoopIsActive: + if not self.application.eventLoopIsActive: event.ignore() return # If we just did a settings import, close without saving changes.