diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2010-09-29 10:56:38 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-10-04 06:36:04 (GMT) |
commit | acc1dc498ea733bab2a1f5ef9983829adbbf5735 (patch) | |
tree | 9b3907b7bde9d81dd83bb745f346562da8e0d5fa /src/gui/graphicsview | |
parent | 6c53410d8104064b53beccb1f2014c980735aefb (diff) | |
download | Qt-acc1dc498ea733bab2a1f5ef9983829adbbf5735.zip Qt-acc1dc498ea733bab2a1f5ef9983829adbbf5735.tar.gz Qt-acc1dc498ea733bab2a1f5ef9983829adbbf5735.tar.bz2 |
Fix double painting when adding an item into a linear layout
the problem was that the item is first painted at its default position,
then moved by the layout and finally repainted.
We now made sure the item is laid out before the first paint event
occurs.
Task-number: QTBUG-13865
Reviewed-by: bnilsen
(cherry picked from commit 33f525e636ef8fa64a15d3e66c56adaea0075bda)
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgraphicslinearlayout.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp index 1588364..7e8d19f 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.cpp +++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp @@ -275,13 +275,17 @@ void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item) qWarning("QGraphicsLinearLayout::insertItem: cannot insert itself"); return; } + Q_ASSERT(item); + + //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(); d->addChildLayoutItem(item); - Q_ASSERT(item); d->fixIndex(&index); d->engine.insertRow(index, d->orientation); new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index), 1, 1, 0, index); - invalidate(); } /*! |