Browse Source

【综合】代码优化

TangChao 7 months ago
parent
commit
94d40c456b

+ 9 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+UndoManager.m

@@ -116,6 +116,9 @@ static NSString *CPDFListViewAnnotationPropertiesObservationContext = @"CPDFList
 
 - (void)PDFPageDidLoadAnnotationNotification:(NSNotification *)notification {
     CPDFAnnotation *annotation = [notification object];
+    if ([annotation.page.document isEqualTo:self.document] == false) {
+        return;
+    }
     if (annotation.page &&
         [annotation isKindOfClass:[CPDFAnnotation class]] &&
         ![annotation isKindOfClass:[CPDFLinkAnnotation class]]) {
@@ -125,6 +128,9 @@ static NSString *CPDFListViewAnnotationPropertiesObservationContext = @"CPDFList
 
 - (void)PDFPageDidAddAnnotationNotification:(NSNotification *)notification {
     CPDFAnnotation *annotation = [notification object];
+    if ([annotation.page.document isEqualTo:self.document] == false) {
+        return;
+    }
     if ([annotation isKindOfClass:[CPDFAnnotation class]] &&
         ![annotation isKindOfClass:[CPDFLinkAnnotation class]]) {
         [self startObservingNotes:@[annotation]];
@@ -133,6 +139,9 @@ static NSString *CPDFListViewAnnotationPropertiesObservationContext = @"CPDFList
 
 - (void)PDFPageDidRemoveAnnotationNotification:(NSNotification *)notification {
     CPDFAnnotation *annotation = [notification object];
+    if ([annotation.page.document isEqualTo:self.document] == false) {
+        return;
+    }
     if (annotation.page &&
         [annotation isKindOfClass:[CPDFAnnotation class]]) {