Don't clamp length against buffer size after applying offset

* If we have a given view length that fits in the buffer, we shouldn't apply the
  offset before clamping. Instead we apply the offset on the buffer length if
  that's what we're using as our size.
This commit is contained in:
baldurk
2020-04-27 13:03:47 +01:00
parent 105f0e4e9f
commit a7b4fe9167
+10 -3
View File
@@ -2494,10 +2494,17 @@ void BufferViewer::OnEventChanged(uint32_t eventId)
if(unclampedLen == UINT64_MAX)
unclampedLen = 0;
if(unclampedLen == 0)
unclampedLen = m_IsBuffer ? m_Ctx.GetBuffer(m_BufferID)->length : 0;
{
uint64_t bufLen = m_IsBuffer ? m_Ctx.GetBuffer(m_BufferID)->length : 0;
uint64_t bufOffs = CurrentByteOffset();
uint64_t clampedLen =
qMin(unclampedLen - CurrentByteOffset(), uint64_t(buf->stride * (MaxVisibleRows + 2)));
if(bufOffs >= bufLen)
unclampedLen = 0;
else
unclampedLen = bufLen - bufOffs;
}
uint64_t clampedLen = qMin(unclampedLen, uint64_t(buf->stride * (MaxVisibleRows + 2)));
if(m_IsBuffer)
{