From d15c49c6e51e543a7b9ec09c6a6645aa847ed132 Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Wed, 13 Dec 2023 15:45:31 +0800 Subject: [PATCH 1/2] Try to workaround the #281 when imagePlayer stopPlaying trigger the Combine Publisher send event --- ...eSwiftUIDemo-watchOS WatchKit App.xcscheme | 25 +++++-------------- SDWebImageSwiftUI/Classes/ImagePlayer.swift | 4 --- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/Example/SDWebImageSwiftUI.xcodeproj/xcshareddata/xcschemes/SDWebImageSwiftUIDemo-watchOS WatchKit App.xcscheme b/Example/SDWebImageSwiftUI.xcodeproj/xcshareddata/xcschemes/SDWebImageSwiftUIDemo-watchOS WatchKit App.xcscheme index 3d1f081f..65df20bc 100644 --- a/Example/SDWebImageSwiftUI.xcodeproj/xcshareddata/xcschemes/SDWebImageSwiftUIDemo-watchOS WatchKit App.xcscheme +++ b/Example/SDWebImageSwiftUI.xcodeproj/xcshareddata/xcschemes/SDWebImageSwiftUIDemo-watchOS WatchKit App.xcscheme @@ -54,10 +54,8 @@ debugDocumentVersioning = "YES" debugServiceExtension = "internal" allowLocationSimulation = "YES"> - + - + - + - - - - - + diff --git a/SDWebImageSwiftUI/Classes/ImagePlayer.swift b/SDWebImageSwiftUI/Classes/ImagePlayer.swift index 4e61e820..e549a7c2 100644 --- a/SDWebImageSwiftUI/Classes/ImagePlayer.swift +++ b/SDWebImageSwiftUI/Classes/ImagePlayer.swift @@ -29,10 +29,6 @@ public final class ImagePlayer : ObservableObject { /// Animation playback mode public var playbackMode: SDAnimatedImagePlaybackMode = .normal - deinit { - player?.stopPlaying() - } - /// Current playing frame image @Published public var currentFrame: PlatformImage? From ce1f95b79b5750caeb013378a0436286985dc87f Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Wed, 13 Dec 2023 16:17:55 +0800 Subject: [PATCH 2/2] Fix the Combine framework warning --- SDWebImageSwiftUI/Classes/ImageManager.swift | 1 + SDWebImageSwiftUI/Classes/ImagePlayer.swift | 1 + SDWebImageSwiftUI/Classes/Indicator/Indicator.swift | 1 + 3 files changed, 3 insertions(+) diff --git a/SDWebImageSwiftUI/Classes/ImageManager.swift b/SDWebImageSwiftUI/Classes/ImageManager.swift index d9bce8fa..668fb3b3 100644 --- a/SDWebImageSwiftUI/Classes/ImageManager.swift +++ b/SDWebImageSwiftUI/Classes/ImageManager.swift @@ -7,6 +7,7 @@ */ import SwiftUI +import Combine import SDWebImage /// A Image observable object for handle image load process. This drive the Source of Truth for image loading status. diff --git a/SDWebImageSwiftUI/Classes/ImagePlayer.swift b/SDWebImageSwiftUI/Classes/ImagePlayer.swift index e549a7c2..0ba09fc5 100644 --- a/SDWebImageSwiftUI/Classes/ImagePlayer.swift +++ b/SDWebImageSwiftUI/Classes/ImagePlayer.swift @@ -7,6 +7,7 @@ */ import SwiftUI +import Combine import SDWebImage /// A Image observable object for handle aniamted image playback. This is used to avoid `@State` update may capture the View struct type and cause memory leak. diff --git a/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift b/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift index 37eb9030..3461b082 100644 --- a/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift +++ b/SDWebImageSwiftUI/Classes/Indicator/Indicator.swift @@ -7,6 +7,7 @@ */ import Foundation +import Combine import SwiftUI /// A type to build the indicator