sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Fix an AssertionError caused by `requestRepaint()` invoked (indirectly) during `paint()` execution in `MapCanvas`. For safety, make sure that a `Unclosed` object is not reused in `IsolineTracer.Level.merge(…)`.
Date Sat, 23 Jan 2021 21:53:40 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 17755f9  Fix an AssertionError caused by `requestRepaint()` invoked (indirectly)
during `paint()` execution in `MapCanvas`. For safety, make sure that a `Unclosed` object
is not reused in `IsolineTracer.Level.merge(…)`.
17755f9 is described below

commit 17755f9469fcede7a68fe45c83befef23d44b762
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sat Jan 23 13:56:33 2021 +0100

    Fix an AssertionError caused by `requestRepaint()` invoked (indirectly) during `paint()`
execution in `MapCanvas`.
    For safety, make sure that a `Unclosed` object is not reused in `IsolineTracer.Level.merge(…)`.
---
 .../src/main/java/org/apache/sis/gui/map/MapCanvas.java      | 12 ++++++++----
 .../apache/sis/internal/processing/image/IsolineTracer.java  |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvas.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvas.java
index 9675146..8d53ffc 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvas.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvas.java
@@ -866,7 +866,7 @@ public abstract class MapCanvas extends PlanarCanvas {
      */
     public final void requestRepaint() {
         contentChangeCount++;
-        if (renderingInProgress == null) {
+        if (renderingInProgress == null && !isRendering.get()) {
             final Delayed delay = new Delayed();
             BackgroundThreads.execute(delay);
             renderingInProgress = delay;    // Set last after we know that the task has been
scheduled.
@@ -895,8 +895,8 @@ public abstract class MapCanvas extends PlanarCanvas {
                 return;
             }
         }
-        renderingStartTime   = System.nanoTime();
-        renderedContentStamp = contentChangeCount;
+        isRendering.set(true);                      // Avoid that `requestRepaint(…)` trig
new paints.
+        renderingStartTime = System.nanoTime();
         /*
          * If a new canvas size is known, inform the parent `PlanarCanvas` about that.
          * It may cause a recomputation of the "objective to display" transform.
@@ -956,6 +956,7 @@ public abstract class MapCanvas extends PlanarCanvas {
             }
         } catch (TransformException | RenderException ex) {
             restoreCursorAfterPaint();
+            isRendering.set(false);
             errorOccurred(ex);
             return;
         }
@@ -966,7 +967,6 @@ public abstract class MapCanvas extends PlanarCanvas {
          */
         changeInProgress.setToTransform(transform);
         transformOnNewImage.setToIdentity();
-        isRendering.set(true);
         if (!transform.isIdentity()) {
             transformDisplayCoordinates(new AffineTransform(
                     transform.getMxx(), transform.getMyx(),
@@ -976,7 +976,10 @@ public abstract class MapCanvas extends PlanarCanvas {
         /*
          * Invoke `createWorker(…)` only after we finished above configuration, because
that method
          * may take a snapshot of current canvas state in preparation for use in background
threads.
+         * Take the value of `contentChangeCount` only now because above code may have indirect
calls
+         * to `requestRepaint()`.
          */
+        renderedContentStamp = contentChangeCount;
         final Renderer context = createRenderer();
         if (context != null && context.initialize(floatingPane)) {
             final Task<?> worker = createWorker(context);
@@ -1175,6 +1178,7 @@ public abstract class MapCanvas extends PlanarCanvas {
      * @see #reset()
      */
     protected void clear() {
+        assert Platform.isFxApplicationThread();
         transform.setToIdentity();
         changeInProgress.setToIdentity();
         invalidObjectiveToDisplay = true;
diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/processing/image/IsolineTracer.java
b/core/sis-feature/src/main/java/org/apache/sis/internal/processing/image/IsolineTracer.java
index 246d8a5..285883e 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/internal/processing/image/IsolineTracer.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/internal/processing/image/IsolineTracer.java
@@ -649,6 +649,7 @@ final class IsolineTracer {
                         fragment.clear();
                     }
                 }
+                entry.setValue(null);       // Let the garbage collector do its work.
             }
         }
 


Mime
View raw message