Skip to content

Commit

Permalink
Merge pull request #90 from SDWebImage/bugfix_animatedImage_rare_crash
Browse files Browse the repository at this point in the history
Fix the issue when dealloc AnimatedImage's native View, the window does not exist and cause internel Crash
  • Loading branch information
dreampiggy authored Mar 29, 2020
2 parents e8dcfc5 + c0f2531 commit ca9922c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions SDWebImageSwiftUI/Classes/AnimatedImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ public struct AnimatedImage : PlatformViewRepresentable {
// This is a hack because of Xcode 11.3 bug, the @Published does not trigger another `updateUIView` call
// Here I have to use UIKit/AppKit API to triger the same effect (the window change implicitly cause re-render)
if let hostingView = AnimatedImage.findHostingView(from: view) {
#if os(macOS)
hostingView.viewDidMoveToWindow()
#else
hostingView.didMoveToWindow()
#endif
if let _ = hostingView.window {
#if os(macOS)
hostingView.viewDidMoveToWindow()
#else
hostingView.didMoveToWindow()
#endif
}
}
self.imageLoading.image = image
self.imageLoading.isLoading = false
Expand Down

0 comments on commit ca9922c

Please sign in to comment.