summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-02-02 03:20:11 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2011-02-02 03:20:11 (GMT)
commit49df52abc004419f35bb6b508fb681c028a7c679 (patch)
tree506c1872db84c0ec67417210806fa4324b792937
parent88b072b3644cfd960367096ae0103e8ddef0d06d (diff)
downloadQt-49df52abc004419f35bb6b508fb681c028a7c679.zip
Qt-49df52abc004419f35bb6b508fb681c028a7c679.tar.gz
Qt-49df52abc004419f35bb6b508fb681c028a7c679.tar.bz2
Avoid index-out-of bounds related crash in Grid
Task-number: QTBUG-16959 Reviewed-by: Martin Jones
-rw-r--r--src/declarative/graphicsitems/qdeclarativepositioners.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml20
2 files changed, 20 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
index 9450647..4560d32 100644
--- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp
+++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp
@@ -939,7 +939,7 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize)
if (i==0)
maxColWidth << 0;
- if (childIndex == positionedItems.count())
+ if (childIndex == visibleItems.count())
break;
const PositionedItem &child = visibleItems.at(childIndex++);
diff --git a/tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml b/tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml
index 1cba598..f93ce67 100644
--- a/tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml
+++ b/tests/auto/declarative/qdeclarativepositioners/data/repeatertest.qml
@@ -12,9 +12,27 @@ Item {
height: 50
z: {if(index == 0){2;}else if(index == 1){1;} else{3;}}
objectName: {if(index == 0){"one";}else if(index == 1){"two";} else{"three";}}
-
}
}
}
}
+
+ //This crashed once (QTBUG-16959) because the repeater ended up on the end of the list
+ //If this grid just instantiates without crashing, then it has not regressed.
+ Grid {
+ id: grid
+ rows: 2
+ flow: Grid.TopToBottom
+
+ Repeater {
+ model: 13
+ Rectangle {
+ color: "goldenrod"
+ width: 100
+ height: 100
+ radius: 10
+ border.width: 1
+ }
+ }
+ }
}