From 90fb667e40c8abd88cc16723789d22e19d7b3dc6 Mon Sep 17 00:00:00 2001 From: dscyrescotti Date: Mon, 17 Jun 2024 20:53:10 +0700 Subject: [PATCH] refactor: clean up --- Memola/Canvas/Contexts/GraphicContext.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Memola/Canvas/Contexts/GraphicContext.swift b/Memola/Canvas/Contexts/GraphicContext.swift index fefd095..b1f8254 100644 --- a/Memola/Canvas/Contexts/GraphicContext.swift +++ b/Memola/Canvas/Contexts/GraphicContext.swift @@ -324,7 +324,8 @@ extension GraphicContext { let bounds = [origin.x - size.width / 2, origin.y - size.height / 2, origin.x + size.width / 2, origin.y + size.height / 2] let photo = Photo(url: photoItem.id, size: size, origin: origin, bounds: bounds, createdAt: .now, bookmark: photoItem.bookmark) tree.insert(photo.element, in: photo.photoBox) - withPersistence(\.backgroundContext) { [_photo = photo, graphicContext = object] context in + withPersistence(\.backgroundContext) { [weak _photo = photo, weak graphicContext = object] context in + guard let _photo else { return } let photo = PhotoObject(\.backgroundContext) photo.imageURL = _photo.url photo.bounds = _photo.bounds