Fix spacing issue
authorAlan Alpert <alan.alpert@nokia.com>
Fri, 19 Aug 2011 00:32:27 +0000 (10:32 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 19 Aug 2011 00:50:31 +0000 (02:50 +0200)
Spacing was being incorrectly applied in circumstances where invisible
items existed at the end of a positioner.

Task-number: QTBUG-20961
Change-Id: I49ebc8e96a1564c0ff2bde1c1bb3f91d3c441488
Reviewed-on: http://codereview.qt.nokia.com/3232
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
src/declarative/items/qsgpositioners.cpp

index df3450e..fca0aa1 100644 (file)
@@ -533,10 +533,11 @@ void QSGColumn::doPositioning(QSizeF *contentSize)
         contentSize->setWidth(qMax(contentSize->width(), child.item->width()));
 
         voffset += child.item->height();
-        if (ii != positionedItems.count() - 1)
-            voffset += spacing();
+        voffset += spacing();
     }
 
+    if (voffset != 0)//If we positioned any items, undo the spacing from the last item
+        voffset -= spacing();
     contentSize->setHeight(voffset);
 }
 
@@ -734,10 +735,11 @@ void QSGRow::doPositioning(QSizeF *contentSize)
         contentSize->setHeight(qMax(contentSize->height(), child.item->height()));
 
         hoffset += child.item->width();
-        if (ii != positionedItems.count() - 1)
-            hoffset += spacing();
+        hoffset += spacing();
     }
 
+    if (hoffset != 0)//If we positioned any items, undo the extra spacing from the last item
+        hoffset -= spacing();
     contentSize->setWidth(hoffset);
 
     if (d->isLeftToRight())