From c36e69338a0d0d9de56f689534cb0ed51e127fc4 Mon Sep 17 00:00:00 2001 From: Peter Staev Date: Sat, 19 Oct 2019 09:26:39 +0300 Subject: [PATCH] fix: memory leak --- iOSPhotoEditor/PhotoEditor+Font.swift | 4 ++++ iOSPhotoEditor/PhotoEditorViewController.swift | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/iOSPhotoEditor/PhotoEditor+Font.swift b/iOSPhotoEditor/PhotoEditor+Font.swift index d67d667ed..124c1f267 100644 --- a/iOSPhotoEditor/PhotoEditor+Font.swift +++ b/iOSPhotoEditor/PhotoEditor+Font.swift @@ -13,6 +13,10 @@ extension PhotoEditorViewController { //Resources don't load in main bundle we have to register the font func registerFont() { + if (UIFont.fontNames(forFamilyName: "icomoon").count != 0) { + return; + } + let bundle = Bundle(for: PhotoEditorViewController.self) let url = bundle.url(forResource: "icomoon", withExtension: "ttf") diff --git a/iOSPhotoEditor/PhotoEditorViewController.swift b/iOSPhotoEditor/PhotoEditorViewController.swift index abfb4b7e8..24ba8ed46 100644 --- a/iOSPhotoEditor/PhotoEditorViewController.swift +++ b/iOSPhotoEditor/PhotoEditorViewController.swift @@ -105,6 +105,15 @@ public final class PhotoEditorViewController: UIViewController { hideControls() } + override public func viewDidDisappear(_ animated: Bool) { + // Cleanup + colorsCollectionViewDelegate.colorDelegate = nil; + colorsCollectionViewDelegate = nil; + + stickersViewController.stickersViewControllerDelegate = nil; + stickersViewController = nil; + } + func configureCollectionView() { let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() layout.itemSize = CGSize(width: 30, height: 30)