Fix a hang when opening a document while another is begin saved.

This commit is contained in:
Damiano Galassi committed 2018-03-15 09:05:34 +01:00
1 parent fbe5c12545
commit 18fecbfc68
1 file changed
+7 -1
+7 -1
View File
@@ -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") ?? ""