]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge branch 'master' into release/1.44.0
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 8 Jun 2020 18:25:18 +0000 (21:25 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 8 Jun 2020 18:25:18 +0000 (21:25 +0300)
Change-Id: Ic3354d21bd649913c1d41590c8dd787aef66603e

bundles/org.simantics.acorn/src/org/simantics/acorn/MainProgram.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/DiagramViewerLoadJob.java
bundles/org.simantics.simulation/src/org/simantics/simulation/history/HistoryUtil.java

index 1e4b5cbac508623fff9fd9d5017043818ce1ee42..52be328eb87ea5de7d9b58fed20e1fe53439f727 100644 (file)
@@ -70,7 +70,7 @@ public class MainProgram implements Runnable, Closeable {
                this.updateSchedules = new ArrayList[CLUSTER_THREADS];
                for(int i=0;i<clusterUpdateThreads.length;i++) {
                        clusterUpdateThreads[i] = Executors.newSingleThreadExecutor(new ClusterThreadFactory("Cluster Updater " + (i+1), false));
-                       updateSchedules[i] = new ArrayList<ClusterUpdateOperation>();
+                       updateSchedules[i] = new ArrayList<>();
                }
        }
 
@@ -93,11 +93,13 @@ public class MainProgram implements Runnable, Closeable {
 
                try {
 
+                       TreeMap<ClusterUID, List<ClusterUpdateOperation>> updates = new TreeMap<>(clusterComparator);
+
                        main:
                        while(alive) {
 
-                               TreeMap<ClusterUID, List<ClusterUpdateOperation>> updates = new TreeMap<ClusterUID, List<ClusterUpdateOperation>>(clusterComparator);
-
+                               if (!updates.isEmpty())
+                                       updates.clear();
                                operationQueue.pumpUpdates(updates);
 
                                if(updates.isEmpty()) {
@@ -165,6 +167,9 @@ public class MainProgram implements Runnable, Closeable {
                for(int i=0;i<CLUSTER_THREADS;i++)
                        updateSchedules[i].clear();
 
+               if (updates.isEmpty())
+                       return;
+
                final Semaphore s = new Semaphore(0);
 
                for(Map.Entry<ClusterUID, List<ClusterUpdateOperation>> entry : updates.entrySet()) {
index decf3356c68b1b72864f738ac1d6ac57b6fb1ea3..dc9d9d1bef72f88c590167b14acc666edf33d19b 100644 (file)
@@ -111,8 +111,8 @@ public class DiagramViewerLoadJob extends DatabaseJob {
                         });
                         END(task);
                     } catch (Throwable t) {
-                        viewer = null;
                         LOGGER.error("Failed to complete loading of diagram {} in the canvas thread", viewer.diagramResource, t);
+                        viewer = null;
                     }
                 }
             });
index 343adefc8686fc2053b6c4b41e9167d0e937372d..6719cf63b2f138d119b4470403c2b21629a2b6ed 100644 (file)
@@ -664,7 +664,7 @@ public class HistoryUtil {
         */
        public static HistoryImportResult importHistoryArchive(HistoryManager history, Path path) throws IOException, HistoryException {
                HistoryImportResult result = new HistoryImportResult();
-               try (RandomAccessBinary rab = new BinaryFile(path.toFile())) {
+               try (RandomAccessBinary rab = new BinaryFile(path.toFile(), "r")) {
                        importHistoryArchive(history, rab, result);
                        return result;
                } catch (IOException e) {