Mon, 05 Feb 2018 19:15:47 +0100
Started removing the use of QObject.sender() because it causes trouble sometimes.
--- a/Cooperation/CooperationClient.py Sun Feb 04 10:56:30 2018 +0100 +++ b/Cooperation/CooperationClient.py Mon Feb 05 19:15:47 2018 +0100 @@ -191,9 +191,12 @@ connection.setGreetingMessage(self.__username, self.__servers[0].serverPort()) - connection.error.connect(self.__connectionError) - connection.disconnected.connect(self.__disconnected) - connection.readyForUse.connect(self.__readyForUse) + connection.error.connect( + lambda err: self.__connectionError(err, connection)) + connection.disconnected.connect( + lambda: self.__disconnected(connection)) + connection.readyForUse.connect( + lambda: self.__readyForUse(connection)) connection.rejected.connect(self.__connectionRejected) def __connectionRejected(self, msg): @@ -204,14 +207,15 @@ """ self.connectionError.emit(msg) - def __connectionError(self, socketError): + def __connectionError(self, socketError, connection): """ Private slot to handle a connection error. @param socketError reference to the error object - (QAbstractSocket.SocketError) + @type QAbstractSocket.SocketError + @param connection connection that caused the error + @type Connection """ - connection = self.sender() if socketError != QAbstractSocket.RemoteHostClosedError: if connection.peerPort() != 0: msg = "* {0}:{1}\n{2}\n".format( @@ -226,23 +230,28 @@ self.cannotConnect.emit() self.removeConnection(connection) - def __disconnected(self): + def __disconnected(self, connection): """ Private slot to handle the disconnection of a chat client. + + @param connection connection that was disconnected + @type Connection """ - connection = self.sender() self.removeConnection(connection) - def __readyForUse(self): + def __readyForUse(self, connection): """ Private slot to handle a connection getting ready for use. + + @param connection connection that got ready for use + @type Connection """ - connection = self.sender() if self.hasConnection(connection.peerAddress(), connection.peerPort()): return connection.newMessage.connect(self.newMessage) - connection.getParticipants.connect(self.__getParticipants) + connection.getParticipants.connect( + lambda: self.__getParticipants(connection)) connection.editorCommand.connect(self.editorCommand) self.__peers[connection.peerAddress()].append(connection) @@ -267,11 +276,14 @@ self.__processParticipants) self.__initialConnection.connectToHost(host, port) - def __getParticipants(self): + def __getParticipants(self, reqConnection): """ Private slot to handle the request for a list of participants. + + @param reqConnection reference to the connection to get + participants for + @type Connection """ - reqConnection = self.sender() participants = [] for connectionList in self.__peers.values(): for connection in connectionList:
--- a/E5Network/E5NetworkMonitor.py Sun Feb 04 10:56:30 2018 +0100 +++ b/E5Network/E5NetworkMonitor.py Mon Feb 05 19:15:47 2018 +0100 @@ -82,7 +82,9 @@ [self.tr("Name"), self.tr("Value")]) self.requestHeadersList.setModel(self.__requestHeaders) self.requestHeadersList.horizontalHeader().setStretchLastSection(True) - self.requestHeadersList.doubleClicked.connect(self.__showHeaderDetails) + self.requestHeadersList.doubleClicked.connect( + lambda index: self.__showHeaderDetails( + index, self.requestHeadersList)) self.__replyHeaders = QStandardItemModel(self) self.__replyHeaders.setHorizontalHeaderLabels( @@ -90,7 +92,8 @@ self.responseHeadersList.setModel(self.__replyHeaders) self.responseHeadersList.horizontalHeader().setStretchLastSection(True) self.responseHeadersList.doubleClicked.connect( - self.__showHeaderDetails) + lambda index: self.__showHeaderDetails( + index, self.responseHeadersList)) self.requestsList.horizontalHeader().setStretchLastSection(True) self.requestsList.verticalHeader().setMinimumSectionSize(-1) @@ -180,19 +183,18 @@ self.__replyHeaders.item(0, 1).setFlags( Qt.ItemIsSelectable | Qt.ItemIsEnabled) - def __showHeaderDetails(self, index): + def __showHeaderDetails(self, index, headerList): """ Private slot to show a dialog with the header details. - @param index index of the entry to show (QModelIndex) + @param index index of the entry to show + @type QModelIndex + @param headerList list requesting the header details + @type QTableView """ if not index.isValid(): return - headerList = self.sender() - if headerList is None: - return - row = index.row() name = headerList.model().data(headerList.model().index(row, 0)) value = headerList.model().data(headerList.model().index(row, 1)) @@ -260,17 +262,16 @@ self.beginInsertRows( QModelIndex(), len(self.requests), len(self.requests)) self.requests.append(req) - req.reply.finished.connect(self.__addReply) + req.reply.finished.connect(lambda: self.__addReply(req.reply)) self.endInsertRows() - def __addReply(self): + def __addReply(self, reply): """ Private slot to add the reply data to the model. + + @param reply reference to the network reply object + @type QNetworkReply """ - reply = self.sender() - if reply is None: - return - offset = len(self.requests) - 1 while offset >= 0: if self.requests[offset].reply is reply:
--- a/Plugins/VcsPlugins/vcsGit/GitDiffGenerator.py Sun Feb 04 10:56:30 2018 +0100 +++ b/Plugins/VcsPlugins/vcsGit/GitDiffGenerator.py Mon Feb 05 19:15:47 2018 +0100 @@ -42,13 +42,17 @@ self.process = QProcess() self.process.finished.connect(self.__procFinished) - self.process.readyReadStandardOutput.connect(self.__readStdout) - self.process.readyReadStandardError.connect(self.__readStderr) + self.process.readyReadStandardOutput.connect( + lambda: self.__readStdout(self.process)) + self.process.readyReadStandardError.connect( + lambda: self.__readStderr(self.process)) self.process2 = QProcess() self.process2.finished.connect(self.__procFinished) - self.process2.readyReadStandardOutput.connect(self.__readStdout) - self.process2.readyReadStandardError.connect(self.__readStderr) + self.process2.readyReadStandardOutput.connect( + lambda: self.__readStdout(self.process2)) + self.process2.readyReadStandardError.connect( + lambda: self.__readStderr(self.process2)) def stopProcesses(self): """ @@ -208,14 +212,16 @@ else: self.__output2.append(line) - def __readStdout(self): + def __readStdout(self, process): """ Private slot to handle the readyReadStandardOutput signal. It reads the output of the process, formats it and inserts it into the contents pane. + + @param process reference to the process providing output + @type QProcess """ - process = self.sender() process.setReadChannel(QProcess.StandardOutput) isTopDiff = process == self.process @@ -225,14 +231,16 @@ 'replace') self.__processLine(line, isTopDiff) - def __readStderr(self): + def __readStderr(self, process): """ Private slot to handle the readyReadStandardError signal. It reads the error output of the process and inserts it into the error pane. + + @param process reference to the process providing error output + @type QProcess """ - if self.process is not None: - s = str(self.process.readAllStandardError(), - self.__ioEncoding, 'replace') - self.__errors.append(s) + s = str(process.readAllStandardError(), self.__ioEncoding, + 'replace') + self.__errors.append(s)
--- a/Plugins/ViewManagerPlugins/Listspace/Listspace.py Sun Feb 04 10:56:30 2018 +0100 +++ b/Plugins/ViewManagerPlugins/Listspace/Listspace.py Mon Feb 05 19:15:47 2018 +0100 @@ -449,7 +449,8 @@ self.currentStack.addWidget(win) self.currentStack.setCurrentWidget(win) editor.captionChanged.connect(self.__captionChange) - editor.cursorLineChanged.connect(self.__cursorLineChanged) + editor.cursorLineChanged.connect( + lambda lineno: self.__cursorLineChanged(lineno, editor)) index = self.editors.index(editor) self.viewlist.setCurrentRow(index) @@ -477,14 +478,15 @@ if fn: self.setEditorName(editor, fn) - def __cursorLineChanged(self, lineno): + def __cursorLineChanged(self, lineno, editor): """ Private slot to handle a change of the current editor's cursor line. - @param lineno line number of the current editor's cursor (zero based) + @param lineno line number of the editor's cursor (zero based) @type int + @param editor reference to the editor + @type Editor """ - editor = self.sender() if editor: fn = editor.getFileName() if fn:
--- a/Plugins/ViewManagerPlugins/Tabview/Tabview.py Sun Feb 04 10:56:30 2018 +0100 +++ b/Plugins/ViewManagerPlugins/Tabview/Tabview.py Mon Feb 05 19:15:47 2018 +0100 @@ -379,7 +379,8 @@ if editor not in self.editors: self.editors.append(editor) editor.captionChanged.connect(self.__captionChange) - editor.cursorLineChanged.connect(self.__cursorLineChanged) + editor.cursorLineChanged.connect( + lambda lineno: self.__cursorLineChanged(lineno, editor)) emptyIndex = self.indexOf(self.emptyLabel) if emptyIndex > -1: @@ -412,7 +413,8 @@ if editor not in self.editors: self.editors.append(editor) editor.captionChanged.connect(self.__captionChange) - editor.cursorLineChanged.connect(self.__cursorLineChanged) + editor.cursorLineChanged.connect( + lambda lineno: self.__cursorLineChanged(lineno, editor)) emptyIndex = self.indexOf(self.emptyLabel) if emptyIndex > -1: self.removeTab(emptyIndex) @@ -451,14 +453,15 @@ self.setTabText(index, txt) self.setTabToolTip(index, fn) - def __cursorLineChanged(self, lineno): + def __cursorLineChanged(self, lineno, editor): """ Private slot to handle a change of the current editor's cursor line. - @param lineno line number of the current editor's cursor (zero based) + @param lineno line number of the editor's cursor (zero based) @type int + @param editor reference to the editor + @type Editor """ - editor = self.sender() if editor and isinstance(editor, QScintilla.Editor.Editor): fn = editor.getFileName() if fn: @@ -472,8 +475,8 @@ @type QWidget """ if isinstance(widget, QScintilla.Editor.Editor): - widget.cursorLineChanged.disconnect(self.__cursorLineChanged) - widget.captionChanged.disconnect(self.__captionChange) + widget.cursorLineChanged.disconnect() + widget.captionChanged.disconnect() self.editors.remove(widget) index = self.indexOf(widget.parent()) else: