diff --git a/openlp/core/app.py b/openlp/core/app.py index 1ecca85f3..29ebcb4f3 100644 --- a/openlp/core/app.py +++ b/openlp/core/app.py @@ -383,10 +383,8 @@ def main(args=None): # Check if an instance of OpenLP is already running. Quit if there is a running instance and the user only wants one server = Server() if server.is_another_instance_running(): - if server.is_already_running(): - server.post_to_server(qt_args) - server.close_server() - sys.exit() + server.post_to_server(qt_args) + sys.exit() else: server.start_server() application.server = server diff --git a/openlp/core/server.py b/openlp/core/server.py index 340f95054..5de6c9fac 100644 --- a/openlp/core/server.py +++ b/openlp/core/server.py @@ -24,6 +24,7 @@ from PyQt5 import QtCore from PyQt5 import QtNetwork +from openlp.core.common.registry import Registry from openlp.core.common.mixins import LogMixin @@ -86,16 +87,16 @@ class Server(QtCore.QObject, LogMixin): Read a record passed to the server and load a service :return: """ - while True: - msg = self._inStream.readLine() - if msg: - self.log_debug("socket msg = " + msg) - Registry().get('service_manager').on_load_service_clicked(msg) + msg = self._inStream.readLine() + if msg: + self.log_debug("socket msg = " + msg) + Registry().get('service_manager').on_load_service_clicked(msg) def close_server(self): """ - Shutdown to local socket server + Shutdown to local socket server and make sure the server is removed. :return: """ if self._server: - self._server.close() \ No newline at end of file + self._server.close() + QtNetwork.QLocalServer.removeServer(self._id)