diff --git a/Source/views/MacawView.swift b/Source/views/MacawView.swift index 1c21593a..92ef2de3 100644 --- a/Source/views/MacawView.swift +++ b/Source/views/MacawView.swift @@ -242,11 +242,13 @@ open class MacawView: MView, MGestureRecognizerDelegate { private func doFindNode(location: CGPoint) -> NodePath? { MGraphicsBeginImageContextWithOptions(self.bounds.size, false, 1.0) - if let ctx = MGraphicsGetCurrentContext() { - return doFindNode(location: location, ctx: ctx) + defer { + MGraphicsEndImageContext() } - MGraphicsEndImageContext() - return .none + guard let ctx = MGraphicsGetCurrentContext() else { + return .none + } + return doFindNode(location: location, ctx: ctx) } // MARK: - Touches