Fix crash when frames not preloaded in time.
This commit is contained in:
parent
aa2e6a11c5
commit
79f01b02ad
|
@ -20,6 +20,12 @@ class GifuTests: XCTestCase {
|
|||
XCTAssertTrue(animator.isAnimatable)
|
||||
}
|
||||
|
||||
func testCurrentFrame() {
|
||||
XCTAssertEqual(animator.currentFrameIndex, 0)
|
||||
XCTAssertEqual(animator.currentFrameDuration, NSTimeInterval.infinity)
|
||||
XCTAssertNil(animator.currentFrameImage)
|
||||
}
|
||||
|
||||
func testFramePreload() {
|
||||
let expectation = expectationWithDescription("frameDuration")
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ class Animator {
|
|||
/// - parameter index: The index of the duration.
|
||||
/// - returns: The duration of the given frame.
|
||||
func durationAtIndex(index: Int) -> NSTimeInterval {
|
||||
return animatedFrames[index].duration
|
||||
return animatedFrames[safe: index]?.duration ?? NSTimeInterval.infinity
|
||||
}
|
||||
|
||||
/// Checks whether the frame should be changed and calls a handler with the results.
|
||||
|
|
Loading…
Reference in New Issue