Fix crash in Flow Controller

This commit is contained in:
Li Tan
2015-01-06 18:04:42 -08:00
parent c4b3efffc9
commit b9c6f3de03

View File

@@ -155,7 +155,7 @@ static const std::pair<int, int> ASFindIndexForRange(const std::vector<std::vect
if (range < 0.0 && cur.first >= 0 && cur.second >= 0) {
// search backward
while (range < 0.0 && cur.second >= 0) {
while (range < 0.0 && cur.first >= 0 && cur.second >= 0) {
pre = cur;
CGSize size = nodes[cur.first][cur.second];
range += layoutDirection == ASFlowLayoutDirectionHorizontal ? size.width : size.height;
@@ -170,7 +170,7 @@ static const std::pair<int, int> ASFindIndexForRange(const std::vector<std::vect
}
} else {
// search forward
while (range > 0.0 && cur.second < nodes[cur.first].size()) {
while (range > 0.0 && cur.first < nodes.size() && cur.second < nodes[cur.first].size()) {
pre = cur;
CGSize size = nodes[cur.first][cur.second];
range -= layoutDirection == ASFlowLayoutDirectionHorizontal ? size.width : size.height;