From 18fecbfc6833c299286e4a9c5ba8589518076d1c Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Thu, 15 Mar 2018 09:05:34 +0100 Subject: [PATCH] Fix a hang when opening a document while another is begin saved. --- Classes/AppDelegate.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Classes/AppDelegate.swift b/Classes/AppDelegate.swift index e1f795a..ab0bc2e 100644 --- a/Classes/AppDelegate.swift +++ b/Classes/AppDelegate.swift @@ -8,6 +8,7 @@ import Cocoa class DocumentController : NSDocumentController { + override func openDocument(withContentsOf url: URL, display displayDocument: Bool, completionHandler: @escaping (NSDocument?, Bool, Error?) -> Void) { let ext = url.pathExtension.lowercased() @@ -26,6 +27,11 @@ class DocumentController : NSDocumentController { super.openDocument(withContentsOf: url, display: displayDocument, completionHandler: completionHandler) } } + + override func document(for url: URL) -> NSDocument? { + let filteredDocuments = self.documents.filter { $0.fileURL == url } + return filteredDocuments.first + } } @NSApplicationMain @@ -73,7 +79,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let firstLaunch = defaults.bool(forKey: "SBFirstLaunch") ? false : true let donateNagTime = Double(60 * 60 * 24 * 7) - let donateNagTimeLong = Double(60 * 60 * 24 * 120) + let donateNagTimeLong = Double(60 * 60 * 24 * 180) let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "" let lastVersion = defaults.string(forKey: "SBDonateAskVersion") ?? ""