0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 08:41:02 +08:00

(EasyGraphicsView) Important fix: fixed wrong indexing on paint

This commit is contained in:
Victor Zarubkin 2016-11-26 17:00:05 +03:00
parent a7ac056021
commit 0658540109
2 changed files with 20 additions and 19 deletions

View File

@ -541,7 +541,7 @@ qreal EasyGraphicsView::setTree(EasyGraphicsItem* _item, ::profiler::block_index
bool warned = false;
qreal total_duration = 0, prev_end = 0, maxh = 0;
qreal start_time = -1;
uint32_t i = 0;
uint32_t j = 0;
for (auto child_index : _children)
{
auto& gui_block = easyBlock(child_index);
@ -567,7 +567,7 @@ qreal EasyGraphicsView::setTree(EasyGraphicsItem* _item, ::profiler::block_index
// duration = MIN_DURATION;
//}
auto i = _item->addItem(level);
const auto i = _item->addItem(level);
auto& b = _item->getItem(level, i);
gui_block.graphics_item = _item->index();
@ -610,12 +610,12 @@ qreal EasyGraphicsView::setTree(EasyGraphicsItem* _item, ::profiler::block_index
b.parent = _parent;
b.setPos(xbegin, duration);
//b.totalHeight = ::profiler_gui::GRAPHICS_ROW_SIZE + h;
b.state = i > 0 || level == 0 ? 0 : -1;
b.state = j > 0 || level == 0 ? 0 : -1;
prev_end = xbegin + duration;
total_duration = prev_end - start_time;
++i;
++j;
}
_height += ::profiler_gui::GRAPHICS_ROW_SIZE_FULL + maxh;

View File

@ -238,10 +238,9 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
if (top > visibleBottom)
break;
int j = 1;
uint32_t par = ~0U;
qreal prevRight = -1e100;
for (uint32_t i = m_levelsIndexes[l], end = static_cast<uint32_t>(level.size()); i < end; ++i)
uint32_t neighbour = 0;
for (uint32_t i = m_levelsIndexes[l], end = static_cast<uint32_t>(level.size()); i < end; ++i, ++neighbour)
{
//++iterations;
@ -252,6 +251,7 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
if (item.state != BLOCK_ITEM_UNCHANGED)
{
neighbour = 0; // first block in parent's children list
state = item.state;
item.state = BLOCK_ITEM_DO_NOT_PAINT;
}
@ -267,8 +267,14 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
{
// This item is not visible
//skip_children(next_level, item.children_begin);
if (item.parent != ~0U)
i += static_cast<uint32_t>(easyBlock(item.parent).tree.children.size()) - 1; // Skip all neighbours
{
const auto n = static_cast<uint32_t>(easyBlock(item.parent).tree.children.size());
if (neighbour < n)
i += n - neighbour - 1; // Skip all neighbours
}
continue;
}
@ -276,20 +282,15 @@ void EasyGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*
{
// Paint only first child which has own children
if (par != item.parent)
j = 1;
par = item.parent;
if (item.children_begin == MAX_CHILD_INDEX && next_level < levelsNumber)
{
// This item has no children and would not be painted
++j;
continue;
}
continue; // This item has no children and would not be painted
if (item.parent != ~0U)
i += static_cast<uint32_t>(easyBlock(item.parent).tree.children.size()) - j; // Skip all neighbours
{
const auto n = static_cast<uint32_t>(easyBlock(item.parent).tree.children.size());
if (neighbour < n)
i += n - neighbour - 1; // Skip all neighbours
}
}
const auto& itemBlock = easyBlock(item.block);