From 0ba8f3b4e157d954f41116bc80b9ba668dfb04bc Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 3 Sep 2019 22:58:17 -0700 Subject: [PATCH] Call the completion block once and only once from FetchRequestOperation. This is a probable fix for #898. --- Mac/MainWindow/Timeline/FetchRequestOperation.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Mac/MainWindow/Timeline/FetchRequestOperation.swift b/Mac/MainWindow/Timeline/FetchRequestOperation.swift index e171f535f..223b2095b 100644 --- a/Mac/MainWindow/Timeline/FetchRequestOperation.swift +++ b/Mac/MainWindow/Timeline/FetchRequestOperation.swift @@ -52,10 +52,14 @@ class FetchRequestOperation { var fetchersReturned = 0 var fetchedArticles = Set
() for articleFetcher in articleFetchers { + var didCallCompletion = false articleFetcher.fetchArticlesAsync { (articles) in precondition(Thread.isMainThread) if self.isCanceled { - completion(self) + if !didCallCompletion { + didCallCompletion = true + completion(self) + } return } fetchedArticles.formUnion(articles)