You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2021/11/28 17:01:28 UTC
[sis] 02/03: Fix a `NullPointerException` when a new resource is opened while another resource was visible.
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
commit 48c634d8b1ef2a3f242d8f7a462c9fab873b9138
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun Nov 28 17:20:53 2021 +0100
Fix a `NullPointerException` when a new resource is opened while another resource was visible.
---
.../java/org/apache/sis/gui/coverage/CoverageCanvas.java | 2 +-
.../org/apache/sis/internal/map/coverage/RenderingData.java | 12 ++----------
2 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java
index 6e3da66..a95c3d5 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java
@@ -623,7 +623,7 @@ public class CoverageCanvas extends MapCanvasAWT {
*/
@Override
protected Renderer createRenderer() {
- return data.isEmpty() ? null : new Worker(this);
+ return (data.getSourceImage() != null || getResource() != null) ? new Worker(this) : null;
}
/**
diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/RenderingData.java b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/RenderingData.java
index 6cba9de..d5ab73f 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/RenderingData.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/coverage/RenderingData.java
@@ -230,20 +230,12 @@ public class RenderingData implements Cloneable {
}
/**
- * Returns {@code true} if this object has no image to render.
- *
- * @return {@code true} if this object has no data.
- */
- public final boolean isEmpty() {
- return data == null && dataGeometry == null && dataRanges == null;
- }
-
- /**
* Clears this renderer. This method should be invoked when the source of data (resource or coverage) changed.
* The {@link #displayToObjective} transform will be recomputed from scratch when first needed.
*/
public final void clear() {
clearCRS();
+ coverageLoader = null;
displayToObjective = null;
statistics = null;
data = null;
@@ -416,7 +408,7 @@ public class RenderingData implements Cloneable {
*
* @return the image loaded be {@link #ensureImageLoaded(GridCoverage, GridExtent)}.
*/
- protected final RenderedImage getSourceImage() {
+ public final RenderedImage getSourceImage() {
return data;
}