Quellcode durchsuchen

【fix】【BOTA】点击大纲按钮,崩溃一次

tangchao vor 10 Monaten
Ursprung
Commit
c54b8f1cfa

+ 9 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -609,6 +609,13 @@ class KMLeftSideViewController: KMSideViewController {
     }
     
     func displayTocViewAnimating(_ animate: Bool) {
+        if Thread.current.isMainThread {
+            self.tocOutlineView.reloadData()
+        } else {
+            Task { @MainActor in
+                self.tocOutlineView.reloadData()
+            }
+        }
         if let data = self.tocOutlineView.enclosingScrollView {
             self.replaceSideView(data, animate: animate)
         }
@@ -1849,12 +1856,12 @@ extension KMLeftSideViewController: NSOutlineViewDelegate, NSOutlineViewDataSour
             if let data = item as? String, data == Self.kOutlineRootBookmarkItem {
                 title = NSLocalizedString("Bookmarks", comment: "")
             } else if let ol = item as? CPDFOutline {
-                title = ol.label
+                title = ol.label ?? ""
                 if ol.actionType == .page {
                     pageLabel = "\((ol.destination?.pageIndex ?? 0) + 1)"
                 }
             } else if let bk = item as? CPDFBookmark {
-                title = bk.label
+                title = bk.label ?? ""
                 pageLabel = "\(bk.pageIndex + 1)"
             }