From 64240f35199c6e4811b44832fb169ed04a187788 Mon Sep 17 00:00:00 2001 From: MSementsov-Ibk Date: Wed, 17 Oct 2018 08:03:30 +0200 Subject: [PATCH] Synchronized Rendering (thread safety) Synchronized Access on layers (and other places where getLayers is accessed). Signed-off-by: Michael Sementsov --- .../locationtech/udig/project/ui/ApplicationGIS.java | 4 +++- .../internal/render/impl/RendererCreatorImpl.java | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/ApplicationGIS.java b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/ApplicationGIS.java index 2558c4fa62..64293c7c07 100644 --- a/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/ApplicationGIS.java +++ b/plugins/org.locationtech.udig.project.ui/src/org/locationtech/udig/project/ui/ApplicationGIS.java @@ -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 sortedContexts = new TreeSet( decisive.getConfiguration()); diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/RendererCreatorImpl.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/RendererCreatorImpl.java index cc93e2edd1..3ceff13b39 100644 --- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/RendererCreatorImpl.java +++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/RendererCreatorImpl.java @@ -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()) { + for (Layer layer : getLayers()) + if (layer instanceof SelectionLayer) + if (((SelectionLayer) layer).getWrappedLayer() == targetLayer) + return (SelectionLayer) layer; - return null; + return null; + } } /**