Revert "Fix double painting when adding an item into a linear layout"
(It did not really fix the issue.) This reverts commit 33f525e636ef8fa64a15d3e66c56adaea0075bda. Conflicts: src/gui/graphicsview/qgraphicslinearlayout.cpp tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp (cherry picked from commit fee052e3e37b3335fe563cb8a1881bf59f9e25d0)
This commit is contained in:
parent
446a7ba4ff
commit
1625b25a9f
@ -275,15 +275,12 @@ void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item)
|
|||||||
qWarning("QGraphicsLinearLayout::insertItem: cannot insert itself");
|
qWarning("QGraphicsLinearLayout::insertItem: cannot insert itself");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->addChildLayoutItem(item);
|
d->addChildLayoutItem(item);
|
||||||
|
|
||||||
|
Q_ASSERT(item);
|
||||||
d->fixIndex(&index);
|
d->fixIndex(&index);
|
||||||
d->engine.insertRow(index, d->orientation);
|
d->engine.insertRow(index, d->orientation);
|
||||||
new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index), 1, 1, 0, index);
|
new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index), 1, 1, 0, index);
|
||||||
//the order of the following instructions is very important because
|
|
||||||
//invalidating the layout before adding the child item will make the layout happen
|
|
||||||
//before we try to paint the item
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,6 @@ private slots:
|
|||||||
void task250119_shortcutContext();
|
void task250119_shortcutContext();
|
||||||
void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems();
|
void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems();
|
||||||
void QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems();
|
void QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems();
|
||||||
void QT_BUG_13865_doublePaintWhenAddingASubItem();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -3367,46 +3366,6 @@ void tst_QGraphicsWidget::QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems()
|
|||||||
//This should not crash
|
//This should not crash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct GreenWidget : public QGraphicsWidget
|
|
||||||
{
|
|
||||||
GreenWidget() : count(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * )
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
painter->setPen(Qt::green);
|
|
||||||
painter->drawRect(option->rect.adjusted(0,0,-1,-1));
|
|
||||||
}
|
|
||||||
|
|
||||||
int count;
|
|
||||||
};
|
|
||||||
|
|
||||||
void tst_QGraphicsWidget::QT_BUG_13865_doublePaintWhenAddingASubItem()
|
|
||||||
{
|
|
||||||
QGraphicsScene scene;
|
|
||||||
QGraphicsView view(&scene);
|
|
||||||
QGraphicsWidget *widget = new QGraphicsWidget;
|
|
||||||
widget->resize(100, 100);
|
|
||||||
scene.addItem(widget);
|
|
||||||
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(widget);
|
|
||||||
|
|
||||||
view.show();
|
|
||||||
QTest::qWaitForWindowShown(&view);
|
|
||||||
QApplication::processEvents();
|
|
||||||
|
|
||||||
|
|
||||||
GreenWidget *sub = new GreenWidget;
|
|
||||||
layout->addItem(sub);
|
|
||||||
|
|
||||||
QTest::qWait(100);
|
|
||||||
QCOMPARE(sub->count, 1); //it should only be painted once
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QTEST_MAIN(tst_QGraphicsWidget)
|
QTEST_MAIN(tst_QGraphicsWidget)
|
||||||
#include "tst_qgraphicswidget.moc"
|
#include "tst_qgraphicswidget.moc"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user