Dax89 / QHexView

A versatile Hexadecimal widget for Qt5

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Render artefacts on top right of Hex Table

audetto opened this issue · comments

Screenshot from 2021-01-10 14-08-50

I have just updated after a long time and realised there are some artefacts on the top right of the Hex panel.
That area is sometimes white sometimes with hex values.

I am still trying to figure out if there is anything specific that triggers it.

It has something to do with another QT window below the Hex Viewer.
But it was not happening before at 2ad23ee.
Is the hex window fully repainted every time?

Bisection points to this: d26bd46.

It looks to be an off-by-one (or similar) around this logic

https://github.com/Dax89/QHexView/blob/master/qhexview.cpp#L249

It is not redrawing all necessary lines.

    const int lineHeight = m_renderer->lineHeight();
    const qint64 first = firstvisible + std::max(0, (r.top() / lineHeight) - 1);
    const qint64 last = firstvisible + (r.bottom() / lineHeight) + 1;
    int count = static_cast<int>((last - first) + 1);

This fixes it, but I cannot yet pinpoint to the exact error.

Here it is

    const quint64 firstVisible = this->firstVisibleLine();
    const int lineHeight = m_renderer->lineHeight();
    const int headerCount = m_renderer->headerLineCount();

    const int first = std::max(0, (r.top() / lineHeight) - headerCount);  // because all lines are moved down by header
    const int last = (r.bottom()  + lineHeight - 1) / lineHeight;  // round up for fractional line
    const int count = (last - first) + 1;

    m_renderer->render(&painter, firstVisible + first, count, firstVisible);

Will provide a PR.