Skip to content

Commit

Permalink
Fix crash in a GIFAnimatedImage extension (#24031)
Browse files Browse the repository at this point in the history
  • Loading branch information
kean authored Jan 30, 2025
1 parent 76a3cd4 commit a6875ba
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Modules/Sources/AsyncImageKit/Views/AsyncImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public final class AsyncImageView: UIView {
if let image {
imageView.configure(image: image)
} else {
imageView.prepareForReuse()
imageView.reset()
}
}
}
Expand Down Expand Up @@ -185,7 +185,7 @@ extension GIFImageView {
}
}

public func prepareForReuse() {
public func reset() {
if isAnimatingGIF {
prepareForReuse()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct ImageViewExtensions {
controller.prepareForReuse()

if let gifView = imageView as? GIFImageView, gifView.isAnimatingGIF {
gifView.prepareForReuse()
gifView.reset()
} else {
imageView.image = nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ final class SiteMediaCollectionCell: UICollectionViewCell, Reusable {
viewModel?.onDisappear()
viewModel = nil

imageView.prepareForReuse()
imageView.reset()
imageView.image = nil
imageView.alpha = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ final class SiteMediaImageView: UIView {
if let image {
imageView.configure(image: image)
} else {
imageView.prepareForReuse()
imageView.reset()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class AnimatedGifAttachmentViewProvider: NSTextAttachmentViewProvider {
guard let animatedImageView = view as? GIFImageView else {
return
}

animatedImageView.prepareForReuse()
animatedImageView.reset()
}

override init(textAttachment: NSTextAttachment, parentView: UIView?, textLayoutManager: NSTextLayoutManager?, location: NSTextLocation) {
Expand Down

0 comments on commit a6875ba

Please sign in to comment.