update m_lastcount correctly in wxBufferedInputStream::Read() when using the buffer associated with another stream and not created by this one
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51662 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1248,12 +1248,15 @@ wxInputStream& wxBufferedInputStream::Read(void *buf, size_t size)
|
|||||||
size -= m_lastcount;
|
size -= m_lastcount;
|
||||||
buf = (char *)buf + m_lastcount;
|
buf = (char *)buf + m_lastcount;
|
||||||
|
|
||||||
// the call to wxStreamBuffer::Read() below will reset our m_lastcount,
|
// the call to wxStreamBuffer::Read() below may reset our m_lastcount
|
||||||
// so save it
|
// (but it also may not do it if the buffer is associated to another
|
||||||
|
// existing stream and wasn't created by us), so save it
|
||||||
size_t countOld = m_lastcount;
|
size_t countOld = m_lastcount;
|
||||||
|
|
||||||
m_i_streambuf->Read(buf, size);
|
// the new count of the bytes read is the count of bytes read this time
|
||||||
|
m_lastcount = m_i_streambuf->Read(buf, size);
|
||||||
|
|
||||||
|
// plus those we had read before
|
||||||
m_lastcount += countOld;
|
m_lastcount += countOld;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user