]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "UI locking fixes for GraphExplorer implementations" into release/1.35.1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 25 Feb 2019 13:53:52 +0000 (13:53 +0000)
committerGerrit Code Review <gerrit2@simantics>
Mon, 25 Feb 2019 13:53:52 +0000 (13:53 +0000)
bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java
bundles/org.simantics.acorn/src/org/simantics/acorn/MainProgram.java
bundles/org.simantics.diagram.connection/src/org/simantics/diagram/connection/rendering/StyledRouteGraphRenderer.java

index 251a80314c32f9dc37f1565597cf061070280f11..172fdd103150f28b88fac4ce604a74723e49b504 100644 (file)
@@ -49,7 +49,6 @@ import org.simantics.db.service.ClusterSetsSupport;
 import org.simantics.db.service.ClusterUID;
 import org.simantics.db.service.EventSupport;
 import org.simantics.db.service.LifecycleSupport;
-import org.simantics.utils.DataContainer;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.logging.TimeLogger;
 import org.slf4j.Logger;
@@ -700,7 +699,7 @@ public class GraphClientImpl2 implements Database.Session {
                                                                LOGGER.info("performUndo " + ccsid);
                                                        performUndo(ccsid, clusterChanges, support);
                                                } catch (DatabaseException e) {
-                                                       e.printStackTrace();
+                                                       LOGGER.error("failed to perform undo for cluster change set {}", ccsid, e);
                                                }
                                        }
                                }
index 8dea16d7fe73a5cc0234a6e00998ad964f184513..ec4d56c211ad54640d6d6f429d8847e8d6bf7760 100644 (file)
@@ -61,6 +61,7 @@ public class MainProgram implements Runnable, Closeable {
                }
        }
 
+       @SuppressWarnings("unchecked")
        MainProgram(GraphClientImpl2 client, ClusterManager clusters) {
 
                this.client = client;
@@ -128,7 +129,7 @@ public class MainProgram implements Runnable, Closeable {
                                try {
                                        swapChunks();
                                } catch (AcornAccessVerificationException | IllegalAcornStateException e) {
-                                   e.printStackTrace();
+                                       LOGGER.error("cluster chunk swapping failed", e);
                                } finally {
                                        clusters.streamLRU.releaseMutex();
                                }
@@ -146,7 +147,7 @@ public class MainProgram implements Runnable, Closeable {
                        }
 
                } catch (Throwable t) {
-                       t.printStackTrace();
+                       LOGGER.error("FATAL: MainProgram died unexpectedly", t);
                } finally {
                        deathBarrier.release();
                }
@@ -356,7 +357,7 @@ public class MainProgram implements Runnable, Closeable {
                 executor.awaitTermination(500, TimeUnit.MILLISECONDS);
                 clusterUpdateThreads[i] = null;
             } catch (InterruptedException e) {
-                e.printStackTrace();
+                LOGGER.error("clusterUpdateThread[{}] termination interrupted", i, e);
             }
         }
     }
index b084e5875714938026400e5a8b6c938659e3ca71..dd9473042152d0c3af43244d9549d63e4c649e4b 100644 (file)
@@ -36,9 +36,13 @@ public class StyledRouteGraphRenderer implements IRouteGraphRenderer, Serializab
 
        protected final ConnectionStyle style;
 
+       private static class Cache {
+               Path2D path = new Path2D.Double();
+               THashSet<RoutePoint> branchPoints = new THashSet<>();
+       }
+
        // Caches to avoid creating new objects all the time during rendering
-       protected transient Path2D path;
-       protected transient THashSet<RoutePoint> branchPoints;
+       protected static ThreadLocal<Cache> caches = ThreadLocal.withInitial(() -> new Cache());
 
        public StyledRouteGraphRenderer(ConnectionStyle style) {
                if (style == null)
@@ -52,14 +56,14 @@ public class StyledRouteGraphRenderer implements IRouteGraphRenderer, Serializab
 
        @Override
        public void render(Graphics2D g, RouteGraph rg) {
-               if (path == null)
-                       path = new Path2D.Double();
+               Cache cache = caches.get();
+               Path2D path = cache.path;
+               THashSet<RoutePoint> branchPoints = cache.branchPoints;
+
                path.reset();
                rg.getPath2D(path);
                style.drawPath(g, path, false);
 
-               if (branchPoints == null)
-                       branchPoints = new THashSet<RoutePoint>();
                branchPoints.clear();
                for(RouteLine line : rg.getLines()) {
                    renderLine(g, line, false);