Browse Source

【2025】【搜索】- 重复右键搜索crash问题修复

yangliuhua 3 weeks ago
parent
commit
5813a25971

+ 11 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -3484,6 +3484,10 @@ struct KMNMWCFlags {
     
     //MARK: 搜索 & 替换
     func showSearchPopWindow(type: KMNBotaSearchType, keyborad: String?, replaceText: String?, results: [KMSearchMode]) {
+        if (self.currentWindowController != nil) && ((self.currentWindowController as? KMSearchReplaceWindowController) != nil) {
+            return
+        }
+        
         let toolMode = self.listView.toolMode
         let isEditing = self.listView.isEditing()
         
@@ -3530,6 +3534,13 @@ struct KMNMWCFlags {
                 viewC?.update(keyborad: handdler.searchKey, replaceKey: handdler.replaceKey, results: handdler.searchSectionResults)
             }
         }
+        
+        winC.closeCallback = { [weak self] in
+            if (self?.currentWindowController != nil) {
+                self?.currentWindowController = nil
+            }
+        }
+        
         let targetView = self.pdfToolbarController?.leftViewButton
         let point = targetView?.convert(targetView?.frame.origin ?? .zero, to: nil) ?? .zero
         // 200 248

+ 2 - 0
PDF Office/PDF Master/KMClass/Left/Search/Window/KMSearchReplaceWindowController.swift

@@ -52,6 +52,7 @@ class KMSearchReplaceWindowController: KMNBaseWindowController {
     
     var replaceCallback: (() -> Void)?
     var itemClick: KMCommonClickBlock?
+    var closeCallback: (() -> Void)?
     
     private var _modalSession: NSApplication.ModalSession?
     
@@ -321,6 +322,7 @@ class KMSearchReplaceWindowController: KMNBaseWindowController {
     @objc private func _closeAction(_ sender: NSButton) {
         self.window?.orderOut(nil)
         self.handdler.clearData()
+        self.closeCallback?()
     }
     
     @objc private func _previousAction(_ sender: NSButton) {