Browse Source

【多页签】右键重命名后,再右键Show in Finder无反应(已修复)

tangchao 1 year ago
parent
commit
11061baf25

+ 13 - 1
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -1515,12 +1515,24 @@ extension KMMainViewController {
                 
                 let fileManager = FileManager.default
                 let newFileURL = fileURL!.deletingLastPathComponent().appendingPathComponent(outputSavePanel.url!.lastPathComponent)
+                var result = true
                 do {
                     try fileManager.moveItem(at: fileURL!, to: newFileURL)
                 } catch {
+                    result = false
                     print("Error renaming file! Threw: \(error.localizedDescription)")
                 }
-                tabController?.title = outputSavePanel.url!.lastPathComponent
+                if (result) {
+                    tabController?.title = outputSavePanel.url!.lastPathComponent
+                    
+                    if let newPdfDocument = CPDFDocument(url: newFileURL) {
+                        self.isSaveKeyChain = false
+                        newPdfDocument.unlock(withPassword: self.document?.password)
+                        if (newPdfDocument.pageCount > 0) {
+                            self.setDocument = newPdfDocument
+                        }
+                    }
+                }
             } else {
                 outputSavePanel.close()
             }

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -443,6 +443,7 @@ import Cocoa
             }
             listView.document = document
             //            listView.document.delegate = self
+            self.listView.layoutDocumentView()
         }
     }