Parcourir la source

【2025】【页面编辑】内存优化

dinglingui il y a 4 mois
Parent
commit
832b455aa8

+ 8 - 8
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNThumbnailView/KMNPageEditViewController.swift

@@ -25,15 +25,15 @@ class KMNPageEditViewController: KMNThumbnailBaseViewController {
          
          backViewBox.fillColor = ComponentLibrary.shared.getComponentColorFromKey("colorBg/layout-pdfView")
          
-         collectionView.menuClickedAction = { point in
-             let menuStruct = self.clickMenu(point: point)
-             if self.groupView != nil {
-                 self.groupView?.clickedAutoHide = false
-                 self.groupView?.groupDelegate = self
-                 self.groupView?.frame = CGRectMake(0, 0, 180, menuStruct.viewHeight)
-                 self.groupView?.updateGroupInfo(menuStruct.menuitems)
+         collectionView.menuClickedAction = {[weak self] point in
+             let menuStruct = self?.clickMenu(point: point)
+             if self?.groupView != nil {
+                 self?.groupView?.clickedAutoHide = false
+                 self?.groupView?.groupDelegate = self
+                 self?.groupView?.frame = CGRectMake(0, 0, 180, menuStruct?.viewHeight ?? 0)
+                 self?.groupView?.updateGroupInfo(menuStruct?.menuitems ?? [])
                  
-                 self.groupView?.showWithPoint(CGPoint(x: point.x, y: point.y - menuStruct.viewHeight), relativeTo: self.collectionView)
+                 self?.groupView?.showWithPoint(CGPoint(x: point.x, y: point.y - (menuStruct?.viewHeight ?? 0)), relativeTo: self?.collectionView)
              }
              return NSMenu()
          }

+ 5 - 5
PDF Office/PDF Master/KMClass/KMNPDFPageEdit/KMNThumbnailView/KMNThumbnailBaseViewController.swift

@@ -249,13 +249,13 @@ class KMNThumbnailBaseViewController: KMNBaseViewController,NSCollectionViewDele
         collectionView.setDraggingSourceOperationMask(.every, forLocal: false)
         collectionView.setDraggingSourceOperationMask(.every, forLocal: true)
         
-        collectionView.collectionSelectChanges = {
-            if self.isChangeIndexPaths == false {
-                let indexpathsz = self.collectionView.selectionIndexPaths
-                let dex:IndexSet = KMNTools.indexpathsToIndexs(indexpaths: indexpathsz)
+        collectionView.collectionSelectChanges = {[weak self] in
+            if self?.isChangeIndexPaths == false {
+                let indexpathsz = self?.collectionView.selectionIndexPaths
+                let dex:IndexSet = KMNTools.indexpathsToIndexs(indexpaths: indexpathsz ?? [])
                 let selectedIndexPathsString = KMNTools.parseIndexSet(indexSet: dex)
                 
-                self.thumbnailBaseViewDelegate?.changeIndexPathsThumbnailViewControlle?(pageEditVC: self, selectionIndexPaths: indexpathsz, selectionStrings: selectedIndexPathsString)
+                self?.thumbnailBaseViewDelegate?.changeIndexPathsThumbnailViewControlle?(pageEditVC: self, selectionIndexPaths: indexpathsz ?? [], selectionStrings: selectedIndexPathsString)
             }
         }
         

+ 8 - 8
PDF Office/PDF Master/KMClass/Left/ThumnailView/KMNThumnailViewController.swift

@@ -29,15 +29,15 @@ class KMNThumnailViewController: KMNThumbnailBaseViewController {
 
         super.viewDidLoad()
         
-        collectionView.menuClickedAction = { point in
-            let menuStruct = self.clickMenu(point: point)
-            if self.groupView != nil {
-                self.groupView?.clickedAutoHide = false
-                self.groupView?.groupDelegate = self
-                self.groupView?.frame = CGRectMake(0, 0, 180, menuStruct.viewHeight)
-                self.groupView?.updateGroupInfo(menuStruct.menuitems)
+        collectionView.menuClickedAction = {[weak self] point in
+            let menuStruct = self?.clickMenu(point: point)
+            if self?.groupView != nil {
+                self?.groupView?.clickedAutoHide = false
+                self?.groupView?.groupDelegate = self
+                self?.groupView?.frame = CGRectMake(0, 0, 180, menuStruct?.viewHeight ?? 0)
+                self?.groupView?.updateGroupInfo(menuStruct?.menuitems ?? [])
                 
-                self.groupView?.showWithPoint(CGPoint(x: point.x, y: point.y - menuStruct.viewHeight), relativeTo: self.collectionView)
+                self?.groupView?.showWithPoint(CGPoint(x: point.x, y: point.y - (menuStruct?.viewHeight ?? 0)), relativeTo: self?.collectionView)
 
             }
             return NSMenu()