diff --git a/src/plugins/qmlprofiler/timelinerenderer.cpp b/src/plugins/qmlprofiler/timelinerenderer.cpp index e2961141c9e2add91413e49a94e01447ac6aef91..366525dbf6f6ac936decaceb61845425a6991ac3 100644 --- a/src/plugins/qmlprofiler/timelinerenderer.cpp +++ b/src/plugins/qmlprofiler/timelinerenderer.cpp @@ -109,16 +109,20 @@ inline void TimelineRenderer::getItemXExtent(int modelIndex, int i, int ¤t qint64 start = m_profilerModelProxy->startTime(modelIndex, i) - m_startTime; if (start > 0) { currentX = start * m_spacing; - itemWidth = qMax(1.0, (qMin(m_profilerModelProxy->duration(modelIndex, i) * - m_spacing, m_spacedDuration))); + itemWidth = m_profilerModelProxy->duration(modelIndex, i) * m_spacing; } else { currentX = -OutOfScreenMargin; // Explicitly round the "start" part down, away from 0, to match the implicit rounding of // currentX in the > 0 case. If we don't do that we get glitches where a pixel is added if // the element starts outside the screen and subtracted if it starts inside the screen. - itemWidth = qMax(1.0, (qMin(m_profilerModelProxy->duration(modelIndex, i) * m_spacing + - floor(start * m_spacing) + OutOfScreenMargin, - m_spacedDuration))); + itemWidth = m_profilerModelProxy->duration(modelIndex, i) * m_spacing + + floor(start * m_spacing) + OutOfScreenMargin; + } + if (itemWidth < MinimumItemWidth) { + currentX -= (MinimumItemWidth - itemWidth) / 2; + itemWidth = MinimumItemWidth; + } else if (itemWidth > m_spacedDuration) { + itemWidth = m_spacedDuration; } } diff --git a/src/plugins/qmlprofiler/timelinerenderer.h b/src/plugins/qmlprofiler/timelinerenderer.h index cb07e8765c193ca00e6b35678e0b097dd0cb3c86..59d7b988c3f73230e6de5e590b99db5bd8d9b60c 100644 --- a/src/plugins/qmlprofiler/timelinerenderer.h +++ b/src/plugins/qmlprofiler/timelinerenderer.h @@ -197,6 +197,8 @@ private: private: static const int OutOfScreenMargin = 3; // margin to make sure the rectangles stay invisible + static const int MinimumItemWidth = 3; + inline void getItemXExtent(int modelIndex, int i, int ¤tX, int &itemWidth); void resetCurrentSelection();