Skip to content

Commit

Permalink
Fix for a crash that can occur if the first index is greater the numb…
Browse files Browse the repository at this point in the history
…er of items. Fix for PT11908273 and PT11875307
  • Loading branch information
willspurgeon-wayfair committed Oct 31, 2017
1 parent a838e8d commit c760425
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Source/Layout/BrickLayoutSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,15 @@ internal class BrickLayoutSection {

let numberOfItems = self.numberOfItems

for index in firstIndex..<numberOfItems {
// Create or Update an attribute at an index. If returned true, continue calculating. If not, break
if !createOrUpdateAttribute(at: index, with: dataSource, x: &x, y: &y, maxY: &maxY, force: false, invalidate: invalidate, frameOfInterest: frameOfInterest, updatedAttributes: updatedAttributes) {
break
if firstIndex < numberOfItems {
for index in firstIndex..<numberOfItems {
// Create or Update an attribute at an index. If returned true, continue calculating. If not, break
if !createOrUpdateAttribute(at: index, with: dataSource, x: &x, y: &y, maxY: &maxY, force: false, invalidate: invalidate, frameOfInterest: frameOfInterest, updatedAttributes: updatedAttributes) {
break
}
}
}

// If rows need to be aligned, make sure the previous lines are checked
handleRow(for: attributes.count - 1, maxHeight: maxY - y, updatedAttributes: updatedAttributes)

Expand Down

0 comments on commit c760425

Please sign in to comment.