Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ea24105

Browse files
Merge pull request #352 from Wtoto/fix/memoryleak
fix: memoryleak
2 parents 451c6df + 765aea0 commit ea24105

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

‎SDWebImageSwiftUI/Classes/ImageViewWrapper.swift‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,21 @@ public class AnimatedImageViewWrapper : PlatformView {
7373
public override init(frame frameRect: CGRect) {
7474
super.init(frame: frameRect)
7575
addSubview(wrapped)
76-
observation = observe(\.wrapped.image, options: [.new]) { _, _ in
76+
observation = observe(\.wrapped.image, options: [.new]) { [weak self] _, _ in
77+
guard let self = self else {
78+
return
79+
}
7780
self.invalidateIntrinsicContentSize()
7881
}
7982
}
8083

8184
public required init?(coder: NSCoder) {
8285
super.init(coder: coder)
8386
addSubview(wrapped)
84-
observation = observe(\.wrapped.image, options: [.new]) { _, _ in
87+
observation = observe(\.wrapped.image, options: [.new]) { [weak self] _, _ in
88+
guard let self = self else {
89+
return
90+
}
8591
self.invalidateIntrinsicContentSize()
8692
}
8793
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /