]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/gallery/GalleryViewer.java
Add isDisposed checking to avoid unexpected NPE
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / gallery / GalleryViewer.java
index ce5687e8486e05b38f4ca2b28efd72fa8af7b9c7..d09ecf4a6b6f753f7f0adbf57060b3a36ac987c1 100644 (file)
@@ -631,8 +631,10 @@ public class GalleryViewer extends ContentViewer {
                 ctx.getThreadAccess().asyncExec(() -> {
                     //System.out.println(Thread.currentThread() + ": update scene graph(" + el + ")");
                     // Update scene graph and repaint.
-                    el.getElementClass().getSingleItem(GalleryItemSGNode.class).update(el);
-                    ctx.getContentContext().setDirty();
+                    if (!ctx.isDisposed()) {
+                        el.getElementClass().getSingleItem(GalleryItemSGNode.class).update(el);
+                        ctx.getContentContext().setDirty();
+                    }
                 });
                 break;
             }
@@ -673,7 +675,7 @@ public class GalleryViewer extends ContentViewer {
 
     static class GalleryItemPainter extends ElementPainter {
         @Override
-        public void paintSelectionFrame(G2DParentNode elementNode, G2DParentNode selectionNode, IElement e, Color color) {
+        public void paintSelectionFrame(int selectionId, G2DParentNode elementNode, G2DParentNode selectionNode, IElement e, Color color) {
             final Shape outline = ElementUtils.getElementBoundsOnDiagram(e);
             Rectangle2D bounds = outline.getBounds2D();
             GeometryUtils.expandRectangle(bounds, 2, 2, 2, 2);