1
1
mirror of https://github.com/exyte/Macaw.git synced 2024-10-26 13:01:25 +03:00

Merge pull request #599 from exyte/bug/597-Fix-memory-leak

Fix #597: Memory leak, close graphics context in doFindNode method
This commit is contained in:
Yuri Strot 2019-06-03 18:17:14 +07:00 committed by GitHub
commit cbe4a5a0c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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