Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some small changes #52

Merged
merged 8 commits into from
Mar 4, 2020
Merged

Some small changes #52

merged 8 commits into from
Mar 4, 2020

Conversation

gtache
Copy link
Contributor

@gtache gtache commented Feb 13, 2020

Fixes #51

@@ -369,13 +369,17 @@ public void updateView(String propertyConstant, Object oldValue, Object newValue
if (PropertyConstants.DOCUMENT_VIEW_ROTATION_CHANGE.equals(propertyConstant) ||
PropertyConstants.DOCUMENT_VIEW_ZOOM_CHANGE.equals(propertyConstant)) {
if (annotationComponents != null) {
for (AbstractAnnotationComponent comp : annotationComponents) {
comp.validate();
synchronized (annotationComponents) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting change, I curious what usage scenario you ran into a concurrency issue? This "should" all be happening on the AWT thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must admit, it was while working on some custom extensions involving adding annotations programmatically on startup to the page(s).
I could probably avoid doing that if there is a way to know if a PageViewComponent for a given Page is loading/going to load and when it has finished doing so.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is is the MetricsPageLoadingListener interface but it might not offer the granularity you need. I'll merge this soon but wan't to get your opinion the interface and what you're trying to get done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, to summarize:
I have one or several files of annotations (that I dumped)
In commonNewDocumentHandling, I go through all the pages and get their annotations (simply to force init them)
After that, I go through all the PageViewComponents and check if their annotationComponents is null : if yes, I add the annotations directly to the Page, otherwise I add it through the documentViewController (to ensure the annotation component will appear on the view). That's also why I synchronize annotationComponents, I guess a component got added while the view was being updated.
Now that you mentioned the AWT thread, I imagine that if I force this whole process to go through this thread, I shouldn't have synchronization problems. Although it wouldn't help if there is a concurrent access to initPageAnnotations (I also marked it synchronized on my end).
Perhaps a PageLoadingListener could be useful here indeed. Knowing when a page is being inited or painted could save me some trouble I guess.

Basically, what I'm looking for is a way to add "atomically" one or more annotations to a page, and if the PageViewComponent linked to this page is shown on screen, also add the related AnnotationComponents.

If you want to see the exact code I can send it to you.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I think I've bumped into this problem a couple times over he years as we've had user that are pulling the annotations int from a database to assemble the document. I don't see any performance issue with he locks but it certainly feels like there should be an API that makes this process a lot simpler to the end users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be a great addition indeed. Interesting to know that we are not the only one trying to do this.

@pcorless pcorless merged commit f99be67 into pcorless:master Mar 4, 2020
@gtache gtache deleted the QoL branch March 4, 2020 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Small changes and bugfix
2 participants