Skip to content

Commit

Permalink
GH-69 Fixes ConcurrentModificationException and possible NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
gtache committed Mar 31, 2021
1 parent 9b73e4a commit 433e8a1
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import java.util.stream.Collectors;

import static org.icepdf.core.util.PropertyConstants.ANNOTATION_COLOR_PROPERTY_PANEL_CHANGE;
import static org.icepdf.ri.util.ViewerPropertiesManager.*;
Expand Down Expand Up @@ -5684,13 +5685,18 @@ public void changeAnnotationsPrivacy(final AnnotationFilter filter, final boolea
final MarkupAnnotation ma = (MarkupAnnotation) a;
ma.setFlag(Annotation.FLAG_PRIVATE_CONTENTS, priv);
ma.setModifiedDate(PDate.formatDateTime(new Date()));
ma.getPopupAnnotation().setFlag(Annotation.FLAG_PRIVATE_CONTENTS, priv);
ma.getPopupAnnotation().setModifiedDate(PDate.formatDateTime(new Date()));
final PopupAnnotation pa = ma.getPopupAnnotation();
if (pa != null) {
pa.setFlag(Annotation.FLAG_PRIVATE_CONTENTS, priv);
pa.setModifiedDate(PDate.formatDateTime(new Date()));
}
final PageViewComponentImpl pvc = (PageViewComponentImpl)
documentViewController.getDocumentViewModel().getPageComponents().get(ma.getPageIndex());
final MarkupAnnotationComponent<?> comp = (MarkupAnnotationComponent<?>) pvc.getComponentFor(ma);
if (comp != null) {
comp.getPopupAnnotationComponent().refreshPopupState();
if (comp.getPopupAnnotationComponent() != null) {
comp.getPopupAnnotationComponent().refreshPopupState();
}
documentViewController.updateAnnotation(comp);
}
});
Expand All @@ -5702,7 +5708,8 @@ private void callOnFilteredAnnotations(final AnnotationFilter filter, final Cons
for (int i = 0; i < pt.getNumberOfPages(); ++i) {
final Page p = pt.getPage(i);
if (p.getAnnotations() != null) {
p.getAnnotations().stream().filter(filter::filter).forEach(toExecute);
final List<Annotation> annotations = p.getAnnotations().stream().filter(filter::filter).collect(Collectors.toList());
annotations.forEach(toExecute);
}
}
}
Expand Down

0 comments on commit 433e8a1

Please sign in to comment.