diff --git a/syncplay/client.py b/syncplay/client.py index 5638eb8..2577c66 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -42,7 +42,8 @@ class SyncClientFactory(ClientFactory): def clientConnectionFailed(self, connector, reason): if not self.reconnecting: - self._client.ui.showErrorMessage(getMessage("en", "connection-failed-notification")) + reactor.callLater(0.1, self._client.ui.showErrorMessage, getMessage("en", "connection-failed-notification"), True) + reactor.callLater(0.1, self._client.stop, True) else: self.clientConnectionLost(connector, reason) @@ -616,6 +617,7 @@ class UiManager(object): def __init__(self, client, ui): self._client = client self.__ui = ui + self.lastError = "" def showMessage(self, message, noPlayer=False, noTimestamp=False): if(not noPlayer): self.showOSDMessage(message) @@ -629,7 +631,9 @@ class UiManager(object): self._client._player.displayMessage(message, duration * 1000) def showErrorMessage(self, message, criticalerror=False): - self.__ui.showErrorMessage(message, criticalerror) + if message <> self.lastError: # Avoid double call bug + self.lastError = message + self.__ui.showErrorMessage(message, criticalerror) def promptFor(self, prompt): return self.__ui.promptFor(prompt) diff --git a/syncplay/players/mpc.py b/syncplay/players/mpc.py index 7d1793e..21355b1 100644 --- a/syncplay/players/mpc.py +++ b/syncplay/players/mpc.py @@ -358,8 +358,8 @@ class MPCHCAPIPlayer(BasePlayer): def __dropIfNotSufficientVersion(self): self._mpcApi.askForVersion() if(not self.__versionUpdate.wait(0.1) or not self._mpcApi.version): - self.__mpcError(getMessage("en", "mpc-version-insufficient-error").format(constants.MPC_MIN_VER)) - self.reactor.callFromThread(self.__client.stop, (True),) + self.reactor.callFromThread(self.__client.ui.showErrorMessage, getMessage("en", "mpc-version-insufficient-error").format(constants.MPC_MIN_VER), True) + self.reactor.callFromThread(self.__client.stop, True) def __testMpcReady(self): if(not self.__preventAsking.wait(10)): @@ -372,7 +372,7 @@ class MPCHCAPIPlayer(BasePlayer): self.__handleUpdatedFilename() self.askForStatus() except Exception, err: - self.__client.ui.showErrorMessage(err.message) + self.reactor.callFromThread(self.__client.ui.showErrorMessage, err.message, True) self.reactor.callFromThread(self.__client.stop) def initPlayer(self, filePath): @@ -458,10 +458,6 @@ class MPCHCAPIPlayer(BasePlayer): self.__setUpStateForNewlyOpenedFile() args = (self._mpcApi.filePlaying, self._mpcApi.fileDuration, self._mpcApi.filePath) self.reactor.callFromThread(self.__client.updateFile, *args) - - def __mpcError(self, err=""): - self.__client.ui.showErrorMessage(err) - self.reactor.callFromThread(self.__client.stop) def sendCustomCommand(self, cmd, val): self._mpcApi.sendRawCommand(cmd, val)