Skip to content

Commit

Permalink
Synchronized Rendering (thread safety)
Browse files Browse the repository at this point in the history
Synchronized Access on layers (and other places where getLayers is accessed).

Signed-off-by: Michael Sementsov <[email protected]>
  • Loading branch information
MSementsov-Ibk committed Oct 17, 2018
1 parent 48711db commit 64240f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,9 @@ public void run(IProgressMonitor monitor)
RendererCreator decisive = new RendererCreatorImpl();
decisive.setContext(tools);

decisive.getLayers().addAll(layersToRender);
synchronized (decisive.getLayers()) {
decisive.getLayers().addAll(layersToRender);
}

SortedSet<RenderContext> sortedContexts = new TreeSet<RenderContext>(
decisive.getConfiguration());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,14 @@ public SelectionLayer findSelectionLayer( ILayer targetLayer ) {
} catch (IOException e) {
return null;
}
for( Layer layer : getLayers() )
if (layer instanceof SelectionLayer)
if (((SelectionLayer) layer).getWrappedLayer() == targetLayer)
return (SelectionLayer) layer;
synchronized (getLayers()) {

This comment has been minimized.

Copy link
@fgdrf

fgdrf Sep 18, 2019

Contributor

Had a look at again and IMHO synchronization should use layers.this as used in other methods, shouldn't it? Please ignore my previous comment ;)

for (Layer layer : getLayers())
if (layer instanceof SelectionLayer)
if (((SelectionLayer) layer).getWrappedLayer() == targetLayer)
return (SelectionLayer) layer;

return null;
return null;
}
}

/**
Expand Down

0 comments on commit 64240f3

Please sign in to comment.