Emit finished at the right places.
This commit is contained in:
parent
29c84f4f20
commit
435f1f45e0
@ -62,7 +62,7 @@ class SpecialNetworkReply(QNetworkReply):
|
|||||||
parent: reference to the parent object (QObject)
|
parent: reference to the parent object (QObject)
|
||||||
|
|
||||||
Emit:
|
Emit:
|
||||||
metaDataChanged and readyRead after initializing.
|
metaDataChanged and readyRead and finished after initializing.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -79,6 +79,7 @@ class SpecialNetworkReply(QNetworkReply):
|
|||||||
self.setAttribute(QNetworkRequest.HttpReasonPhraseAttribute, "OK")
|
self.setAttribute(QNetworkRequest.HttpReasonPhraseAttribute, "OK")
|
||||||
self.metaDataChanged.emit()
|
self.metaDataChanged.emit()
|
||||||
self.readyRead.emit()
|
self.readyRead.emit()
|
||||||
|
self.finished.emit()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def abort(self):
|
def abort(self):
|
||||||
@ -91,12 +92,7 @@ class SpecialNetworkReply(QNetworkReply):
|
|||||||
Return:
|
Return:
|
||||||
bytes available (int)
|
bytes available (int)
|
||||||
|
|
||||||
Emit:
|
|
||||||
finished: if the data length is 0
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if self._data.length() == 0:
|
|
||||||
self.finished.emit()
|
|
||||||
return self._data.length() + super().bytesAvailable()
|
return self._data.length() + super().bytesAvailable()
|
||||||
logging.debug("bytes available: {}".format(len(self._data)))
|
logging.debug("bytes available: {}".format(len(self._data)))
|
||||||
|
|
||||||
@ -109,14 +105,9 @@ class SpecialNetworkReply(QNetworkReply):
|
|||||||
Return:
|
Return:
|
||||||
bytestring containing the data
|
bytestring containing the data
|
||||||
|
|
||||||
Emit:
|
|
||||||
finished: if all data was read
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
len_ = min(maxlen, self._data.length())
|
len_ = min(maxlen, self._data.length())
|
||||||
buf = bytes(self._data[:len_])
|
buf = bytes(self._data[:len_])
|
||||||
self._data.remove(0, len_)
|
self._data.remove(0, len_)
|
||||||
if self._data.length() == 0:
|
|
||||||
self.finished.emit()
|
|
||||||
logging.debug("readdata, len {}, maxlen {}, buf {}".format(len(self._data), maxlen, buf))
|
logging.debug("readdata, len {}, maxlen {}, buf {}".format(len(self._data), maxlen, buf))
|
||||||
return buf
|
return buf
|
||||||
|
Loading…
Reference in New Issue
Block a user