diff --git a/imagescrollareagl.cpp b/imagescrollareagl.cpp index 9def140..8d11a5d 100644 --- a/imagescrollareagl.cpp +++ b/imagescrollareagl.cpp @@ -366,7 +366,9 @@ void ImageWidget::paintGL() QPainter painter(this); const int w = width()/THUMB_SIZE_BORDER; const int off = (THUMB_SIZE_BORDER - THUMB_SIZE) / 2; - for(int i=0; i < m_thumbnailCount; i++) + int start = std::max((int)(m_dy / THUMB_SIZE_BORDER_Y * w - w), 0); + int end = std::min((int)(m_dy + m_height) / THUMB_SIZE_BORDER_Y * w + w, m_thumbnailCount); + for(int i=start; i < end; i++) { float x = (i % w) * THUMB_SIZE_BORDER; float y = i / w * THUMB_SIZE_BORDER_Y + THUMB_SIZE - m_dy + off;