Browse Source

[首页] - OCR 选择图片crash

liujiajie 11 months ago
parent
commit
050a2cc5d8

+ 6 - 2
PDF Office/PDF Master/Class/PDFTools/OCRNew/Controller/KMOCRPDFWindowController.swift

@@ -97,7 +97,7 @@ class KMOCRPDFWindowController: NSWindowController, NSWindowDelegate, KMGOCRMana
         self.pdfDocument = cpdfDocument
         self.password = pwd ?? ""
         let url: URL? = cpdfDocument.documentURL
-        var lastPathComponent = url?.deletingPathExtension()
+        let lastPathComponent = url?.deletingPathExtension()
         if let str = lastPathComponent?.lastPathComponent {
             if str.count > 0 {
                 self.pathFile = str
@@ -110,7 +110,11 @@ class KMOCRPDFWindowController: NSWindowController, NSWindowDelegate, KMGOCRMana
         
         self._fileAttri = KMFileAttribute()
         self._fileAttri?.password = self.pdfDocument?.password ?? ""
-        self._fileAttri?.filePath = self.pdfDocument?.documentURL.path ?? ""
+        if self.pdfDocument?.documentURL != nil && self.pdfDocument?.documentURL.path != nil{
+            self._fileAttri?.filePath = self.pdfDocument?.documentURL.path ?? ""
+        }else {
+            self._fileAttri?.filePath = ""
+        }
     }
     
     convenience init(filePath: String, pwd: String?) {