--- a/src/eric7/RemoteServerInterface/EricServerDebuggerInterface.py Sat Feb 10 11:28:58 2024 +0100 +++ b/src/eric7/RemoteServerInterface/EricServerDebuggerInterface.py Sun Feb 11 18:35:44 2024 +0100 @@ -22,6 +22,8 @@ """ debugClientResponse = pyqtSignal(str) + debugClientDisconnected = pyqtSignal(str) + lastClientExited = pyqtSignal() def __init__(self, serverInterface): """ @@ -33,12 +35,14 @@ super().__init__(parent=serverInterface) self.__serverInterface = serverInterface + self.__clientStarted = False self.__replyMethodMapping = { "DebuggerRequestError": self.__handleDbgRequestError, "DebugClientResponse": self.__handleDbgClientResponse, "DebugClientDisconnected": self.__handleDbgClientDisconnected, "LastDebugClientExited": self.__handleLastDbgClientExited, + "MainClientExited": self.__handleMainClientExited, } # connect some signals @@ -119,11 +123,9 @@ @param params dictionary containing the reply data @type dict """ - ericApp().getObject("DebugServer").signalClientDisconnected( - params["debugger_id"] - ) + self.debugClientDisconnected.emit(params["debugger_id"]) - def __handleLastDbgClientExited(self, params): + def __handleLastDbgClientExited(self, params): # noqa: U100 """ Private method to handle a report of the eric-ide server, that the last debug client has disconnected. @@ -131,7 +133,18 @@ @param params dictionary containing the reply data @type dict """ - ericApp().getObject("DebugServer").signalLastClientExited() + self.__clientStarted = False + self.lastClientExited.emit() + + def __handleMainClientExited(self, params): # noqa: U100 + """ + Private method to handle the main client exiting. + + @param params dictionary containing the reply data + @type dict + """ + self.__clientStarted = False + ericApp().getObject("DebugServer").signalMainClientExit() ####################################################################### ## Methods for sending debug server commands to the eric-ide server. @@ -160,15 +173,16 @@ "working_dir": FileSystemUtilities.plainFileName(workingDir), }, ) + self.__clientStarted = True def stopClient(self): """ Public method to stop the debug client synchronously. """ - if self.__serverInterface.isServerConnected(): + if self.__serverInterface.isServerConnected() and self.__clientStarted: loop = QEventLoop() - def callback(reply, params): + def callback(reply, params): # noqa: U100 """ Function to handle the server reply @@ -188,3 +202,4 @@ ) loop.exec() + self.__clientStarted = False