Revision: 15428 http://sourceforge.net/p/skim-app/code/15428 Author: hofman Date: 2025-06-10 16:26:32 +0000 (Tue, 10 Jun 2025) Log Message: ----------- don't reset widgets from replace when changing it from read data
Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-10 16:16:27 UTC (rev 15427) +++ trunk/SKMainWindowController.m 2025-06-10 16:26:32 UTC (rev 15428) @@ -911,7 +911,8 @@ placeholderWidgetProperties = nil; } -- (void)updateWidgetsWithProperties:(NSArray *)widgetDicts { +- (void)updateWidgetsWithProperties:(NSArray *)widgetDicts reset:(BOOL)reset { + NSMutableSet *unsetWidgets = reset && [widgets count] ? [NSMutableSet setWithArray:widgets] : nil; if (widgets == nil) { widgets = [[NSMutableArray alloc] init]; widgetValues = [NSMapTable strongToStrongObjectsMapTable]; @@ -934,11 +935,19 @@ id value = [dict objectForKey:widgetType == kSKNPDFWidgetTypeButton ? SKNPDFAnnotationStateKey : SKNPDFAnnotationStringValueKey]; if ([([annotation objectValue] ?: @"") isEqual:(value ?: @"")] == NO) [annotation setObjectValue:value]; + [unsetWidgets removeObject:annotation]; break; } } } } + if ([unsetWidgets count]) { + for (PDFAnnotation *widget in unsetWidgets) { + id origValue = [widgetValues objectForKey:widget]; + if ([([widget objectValue] ?: @"") isEqual:(origValue ?: @"")] == NO) + [widget setObjectValue:origValue]; + } + } } - (NSArray *)widgetProperties { @@ -1050,15 +1059,7 @@ [pdfView setCurrentAnnotation:nil]; } - if (replacing && [widgets count]) { - for (PDFAnnotation *widget in widgets) { - id origValue = [widgetValues objectForKey:widget]; - if ([([widget objectValue] ?: @"") isEqual:(origValue ?: @"")] == NO) - [widget setObjectValue:origValue]; - } - } - if ([widgetDicts count]) - [self updateWidgetsWithProperties:widgetDicts]; + [self updateWidgetsWithProperties:widgetDicts reset:replacing]; [self addAnnotations:notesAndPagesToAdd removeAnnotations:replacing ? [self notes] : nil]; } @@ -1183,7 +1184,7 @@ if ([pdfDocument isLocked]) placeholderWidgetProperties = [widgetProperties count] ? [widgetProperties copy] : nil; else - [self updateWidgetsWithProperties:widgetProperties]; + [self updateWidgetsWithProperties:widgetProperties reset:NO]; [self updatePageLabelsAndOutlineForExpansionState:openState]; [self updateNoteSelection]; @@ -2162,7 +2163,7 @@ if (placeholderWidgetProperties) [[[self document] undoManager] disableUndoRegistration]; - [self updateWidgetsWithProperties:placeholderWidgetProperties]; + [self updateWidgetsWithProperties:placeholderWidgetProperties reset:NO]; if (placeholderWidgetProperties) [[[self document] undoManager] enableUndoRegistration]; placeholderWidgetProperties = nil; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit