Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEM-2476 weak self in blocks #9

Merged
merged 1 commit into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Sources/MetalScope/InterfaceOrientationUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ internal final class InterfaceOrientationUpdater {
UIDevice.current.beginGeneratingDeviceOrientationNotifications()

let observer = NotificationCenter.default.addObserver(forName: UIDevice.orientationDidChangeNotification, object: nil, queue: .main) { [weak self] _ in
guard UIDevice.current.orientation.isValidInterfaceOrientation, self?.isTransitioning == false else {
guard let self = self else { return }
guard UIDevice.current.orientation.isValidInterfaceOrientation, self.isTransitioning == false else {
return
}
self?.updateInterfaceOrientation()
self.updateInterfaceOrientation()
}

deviceOrientationDidChangeNotificationObserver = observer
Expand Down
5 changes: 3 additions & 2 deletions Sources/MetalScope/PanoramaPanGestureManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ final class PanoramaPanGestureManager {
let recognizer = AdvancedPanGestureRecognizer()
recognizer.addTarget(self, action: #selector(handlePanGesture(_:)))
recognizer.earlyTouchEventHandler = { [weak self] in
self?.stopAnimations()
self?.resetReferenceAngles()
guard let self = self else { return }
self.stopAnimations()
self.resetReferenceAngles()
}
return recognizer
}()
Expand Down
3 changes: 2 additions & 1 deletion Sources/MetalScope/RenderLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public final class RenderLoop {
time = sender.timestamp + sender.duration
}
queue.async { [weak self] in
self?.action(time)
guard let self = self else { return }
self.action(time)
}
}
}
6 changes: 4 additions & 2 deletions Sources/MetalScope/VideoScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public final class MonoSphericalVideoScene: MonoSphericalMediaScene, VideoScene

private lazy var renderLoop: RenderLoop = {
return RenderLoop { [weak self] time in
self?.renderVideo(atTime: time)
guard let self = self else { return }
self.renderVideo(atTime: time)
}
}()

Expand Down Expand Up @@ -150,7 +151,8 @@ public final class StereoSphericalVideoScene: StereoSphericalMediaScene, VideoSc

private lazy var renderLoop: RenderLoop = {
return RenderLoop { [weak self] time in
self?.renderVideo(atTime: time)
guard let self = self else { return }
self.renderVideo(atTime: time)
}
}()

Expand Down
3 changes: 2 additions & 1 deletion Sources/PlayerWrappers/VRPlayerWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ extension VRPlayerWrapper: SCNSceneRendererDelegate {
func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
// please make sure to update the indicator on main thread
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
PKLog.debug("updateOrientation")
self?.orientationIndicator?.updateOrientation()
self.orientationIndicator?.updateOrientation()
}
}
}