Skip to content

Commit 2e0b334

Browse files
authored
Fix retain cycle (#74)
1 parent 327e18a commit 2e0b334

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/SnapshotPreviewsCore/View+Snapshot.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ extension View {
3535

3636
let (windowRootVC, containerVC) = Self.setupRootVC(subVC: controller)
3737
window.rootViewController = windowRootVC
38-
controller.expansionSettled = { renderingMode, precision in
38+
controller.expansionSettled = { [weak containerVC, weak controller] renderingMode, precision in
39+
guard let containerVC, let controller else { return }
40+
3941
if async {
4042
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
4143
completion(Self.takeSnapshot(layout: layout, renderingMode: renderingMode, rootVC: containerVC, controller: controller), precision)

0 commit comments

Comments
 (0)