Browse Source

【编辑工具】背景颜色选择crash优化

lizhe 1 year ago
parent
commit
0a5689b6ff

+ 178 - 11
PDF Office/PDF Master.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -4624,6 +4624,21 @@
                   endingLineNumber = "1715"
                   offsetFromSymbolStart = "516">
                </Location>
+               <Location
+                  uuid = "E7F4D56E-1C39-4024-BBA5-68C70086BBFF - 4ec6470d2fdb249d"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMMainViewController.pdfViewEditingSelectionDidChanged(Swift.Optional&lt;__C.CPDFView&gt;) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1715"
+                  endingLineNumber = "1715"
+                  offsetFromSymbolStart = "1336">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -5716,6 +5731,21 @@
                   endingLineNumber = "1527"
                   offsetFromSymbolStart = "120">
                </Location>
+               <Location
+                  uuid = "2237DD70-B8BE-49EA-A4CE-79A8782755B0 - d41263d42370e459"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMMainViewController.clearSaveWatermarkFlag() -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1529"
+                  endingLineNumber = "1529"
+                  offsetFromSymbolStart = "44">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -6139,6 +6169,21 @@
                   endingLineNumber = "481"
                   offsetFromSymbolStart = "20">
                </Location>
+               <Location
+                  uuid = "5B80F998-3B3F-4A3F-842D-1EDB32380522 - e234b4ac8a61f3d0"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMToolbarController.exitPageEditToolbarViewController(PDF_Master.KMToolbarViewController) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/Toolbar/KMToolbarController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "479"
+                  endingLineNumber = "479"
+                  offsetFromSymbolStart = "20">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -7916,6 +7961,21 @@
                   endingLineNumber = "1556"
                   offsetFromSymbolStart = "2672">
                </Location>
+               <Location
+                  uuid = "62BC6468-594C-4A01-ADDD-BBD0C1BEAB50 - c14e260fc59c1dae"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMMainViewController.documentDidUnlockNotification(Foundation.Notification) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1557"
+                  endingLineNumber = "1557"
+                  offsetFromSymbolStart = "1728">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -10813,6 +10873,21 @@
                   endingLineNumber = "1319"
                   offsetFromSymbolStart = "1648">
                </Location>
+               <Location
+                  uuid = "EB3CC863-CD88-4969-8755-C4ABD9B1445B - 7ed121a0830bc0d"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "closure #1 @Swift.MainActor () -&gt; () in PDF_Master.KMMainViewController.needShowRegisterView() -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1319"
+                  endingLineNumber = "1319"
+                  offsetFromSymbolStart = "692">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -13723,6 +13798,21 @@
                   endingLineNumber = "1788"
                   offsetFromSymbolStart = "11752">
                </Location>
+               <Location
+                  uuid = "92E48F43-EDDA-41B9-AC18-29D691252B4A - 41c232057cc11a70"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMMainViewController.pdfViewEditingAreaDidChanged(Swift.Optional&lt;__C.CPDFView&gt;) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1788"
+                  endingLineNumber = "1788"
+                  offsetFromSymbolStart = "10484">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -14934,6 +15024,21 @@
                   endingLineNumber = "877"
                   offsetFromSymbolStart = "60">
                </Location>
+               <Location
+                  uuid = "022F293D-ED6A-47AE-B2B5-BF53C2EFBC64 - 4a79ea145b5d1d7d"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "closure #1 (Swift.Int) -&gt; () in PDF_Master.KMMainViewController.exeRedactConfirm(_: PDF_Master.KMRedactConfirmType, callback: () -&gt; Swift.Optional&lt;()&gt;) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "877"
+                  endingLineNumber = "877"
+                  offsetFromSymbolStart = "3896">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -15137,6 +15242,21 @@
                   endingLineNumber = "884"
                   offsetFromSymbolStart = "56">
                </Location>
+               <Location
+                  uuid = "413CB931-992A-496A-9810-2C75366C21AA - f41c97da87780c0e"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMMainViewController.showSecureSuccessTip() -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "884"
+                  endingLineNumber = "884"
+                  offsetFromSymbolStart = "144">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -15839,6 +15959,21 @@
                   endingLineNumber = "1043"
                   offsetFromSymbolStart = "148">
                </Location>
+               <Location
+                  uuid = "D849E96F-D566-4F07-8763-C431124F4A67 - e1d8b7def499748f"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "closure #1 @Swift.MainActor () -&gt; () in PDF_Master.KMMainViewController.showMergeWindow(url: Swift.Optional&lt;Foundation.URL&gt;, _: Swift.Optional&lt;Swift.String&gt;) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Volumes/Data/Company/kdan/Projects/PDF%20Office/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "1010"
+                  endingLineNumber = "1010"
+                  offsetFromSymbolStart = "4528">
+               </Location>
             </Locations>
          </BreakpointContent>
       </BreakpointProxy>
@@ -16104,10 +16239,10 @@
             filePath = "PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "667"
-            endingLineNumber = "667"
-            landmarkName = "KMAddBackgroundView"
-            landmarkType = "3">
+            startingLineNumber = "716"
+            endingLineNumber = "716"
+            landmarkName = "tagString()"
+            landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
@@ -16120,9 +16255,9 @@
             filePath = "PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "755"
-            endingLineNumber = "755"
-            landmarkName = "verticalStepperAction(_:)"
+            startingLineNumber = "809"
+            endingLineNumber = "809"
+            landmarkName = "alphaSteperAction(_:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
@@ -16136,10 +16271,10 @@
             filePath = "PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "764"
-            endingLineNumber = "764"
-            landmarkName = "horizentalStepperAction(_:)"
-            landmarkType = "7">
+            startingLineNumber = "818"
+            endingLineNumber = "818"
+            landmarkName = "KMAddBackgroundView"
+            landmarkType = "21">
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
@@ -16636,5 +16771,37 @@
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "DA751D24-43E3-43D3-A7EB-42AFF4C16497"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "744"
+            endingLineNumber = "744"
+            landmarkName = "colorWellDidChange(_:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "E9E96445-B318-4676-A30F-E9E692C68707"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "414"
+            endingLineNumber = "414"
+            landmarkName = "reloadDocument()"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
    </Breakpoints>
 </Bucket>

+ 47 - 16
PDF Office/PDF Master/Class/PDFTools/Background/New/View/KMAddBackgroundView.swift

@@ -67,6 +67,8 @@ class KMAddBackgroundView: KMBaseXibView, NSComboBoxDelegate {
     
     var isHiddenBatchBtn: Bool = false
     
+    private var workItem: DispatchWorkItem?
+    
     lazy var background: KMBackgroundModel = {
         var bg = KMBackgroundModel()
         bg.type = .color
@@ -96,6 +98,7 @@ class KMAddBackgroundView: KMBaseXibView, NSComboBoxDelegate {
             self.reloadData()
         }
     }
+    
     var backgroundType: KMBackgroundType = .color
         
     var initialID: String!
@@ -237,6 +240,10 @@ class KMAddBackgroundView: KMBaseXibView, NSComboBoxDelegate {
         pageRangeComboBox.selectItem(at: 0)
         pageRangeComboBox.isEditable = false
         pageRangeComboBox.delegate = self
+        
+        
+        colorWell.target = self
+        colorWell.action = #selector(colorWellDidChange)
     }
     
     override func addNotification() {
@@ -369,6 +376,40 @@ class KMAddBackgroundView: KMBaseXibView, NSComboBoxDelegate {
 //        pdfView.needsDisplay = true
 //        pdfView.layoutDocumentView()
 //        pdfView.setNeedsDisplayForVisiblePages()
+        
+
+//        // Save to temporary path
+//        let documentPath = NSTemporaryDirectory()
+//        let tempPath = (documentPath as NSString).appendingPathComponent((path as NSString).lastPathComponent)
+//        try? FileManager.default.removeItem(atPath: tempPath)
+//
+//        let result = document.write(to: URL(fileURLWithPath: tempPath))
+//        if result {
+//            if FileManager.default.fileExists(atPath: path) {
+//                try? FileManager.default.removeItem(atPath: path)
+//            }
+//            try? FileManager.default.moveItem(atPath: tempPath, toPath: path)
+//        } else {
+//            try? FileManager.default.removeItem(atPath: tempPath)
+//        }
+        
+        // 如果前一次调用还在执行,则取消它
+        workItem?.cancel()
+
+        // 创建一个新的 DispatchWorkItem
+        let newWorkItem = DispatchWorkItem {
+            // 在这里执行你的方法的实际逻辑
+            self.reloadDocument()
+        }
+
+        // 将新的 DispatchWorkItem 分配给实例变量
+        workItem = newWorkItem
+
+        // 在队列中执行 DispatchWorkItem
+        DispatchQueue.main.async(execute: newWorkItem)
+    }
+    
+    func reloadDocument() {
         let document = CPDFDocument(url: self.pdfDocument?.documentURL)
         guard let document = document else { return }
         document.unlock(withPassword: self.pdfDocument?.password)
@@ -400,21 +441,6 @@ class KMAddBackgroundView: KMBaseXibView, NSComboBoxDelegate {
 
         tBackground.update()
         self.pdfView.document = document
-
-//        // Save to temporary path
-//        let documentPath = NSTemporaryDirectory()
-//        let tempPath = (documentPath as NSString).appendingPathComponent((path as NSString).lastPathComponent)
-//        try? FileManager.default.removeItem(atPath: tempPath)
-//
-//        let result = document.write(to: URL(fileURLWithPath: tempPath))
-//        if result {
-//            if FileManager.default.fileExists(atPath: path) {
-//                try? FileManager.default.removeItem(atPath: path)
-//            }
-//            try? FileManager.default.moveItem(atPath: tempPath, toPath: path)
-//        } else {
-//            try? FileManager.default.removeItem(atPath: tempPath)
-//        }
     }
 
     // Other methods...
@@ -709,7 +735,12 @@ extension KMAddBackgroundView {
         changeTypeBoxState(sender as? NSObject == colorButton)
     }
 
-    @IBAction func colorWellChanged(_ sender: NSColorWell) {
+//    @IBAction func colorWellChanged(_ sender: NSColorWell) {
+//        background.color = sender.color
+//        self.updatePDFView()
+//    }
+    
+    @objc func colorWellDidChange(_ sender: NSColorWell) {
         background.color = sender.color
         self.updatePDFView()
     }