Browse Source

【综合】ocr偶发crash修复

tangchao 11 months ago
parent
commit
01cccb1ab0

+ 2 - 3
PDF Office/PDF Master/Class/PDFTools/Merge/Model/KMFileAttribute.swift

@@ -46,14 +46,13 @@ import Cocoa
     func reloadData() {
         if filePath.count != 0 {
             let attribe = try?FileManager.default.attributesOfItem(atPath: filePath)
-            fileSize = attribe?[FileAttributeKey.size] as! CGFloat
+            fileSize = attribe?[FileAttributeKey.size] as? CGFloat ?? 0
             
             let document = CPDFDocument.init(url: URL(fileURLWithPath: filePath))
             document?.unlock(withPassword: self.password)
-            isLocked = document!.isLocked
+            isLocked = document?.isLocked ?? false
             self.pdfDocument = document
             
-            
             let page = document?.page(at: 0) ?? CPDFPage()
             let image = page.thumbnail(of: page.size)
             fileImage = image ?? NSImage()