altosuilib: Don't try to draw to destroyed map windows
[fw/altos] / altosuilib / AltosSiteMapImage.java
index f08c0b261dd3e6db52b7d903aa5d59a940e19dfa..f1cfa7c0a790a4be44c56605f663d03169614bb3 100644 (file)
@@ -34,7 +34,7 @@ public class AltosSiteMapImage {
 
        Thread  load_thread;
 
 
        Thread  load_thread;
 
-       public boolean validate() {
+       public boolean validate(final int serial) {
                if (image != null) {
                        AltosSiteMap.debug_component(tile, "valid");
                        return true;
                if (image != null) {
                        AltosSiteMap.debug_component(tile, "valid");
                        return true;
@@ -42,16 +42,16 @@ public class AltosSiteMapImage {
                        AltosSiteMap.debug_component(tile, "loading");
                        load_thread = new Thread() {
                                        public void run() {
                        AltosSiteMap.debug_component(tile, "loading");
                        load_thread = new Thread() {
                                        public void run() {
-                                               image = null;
                                                try {
                                                        image = ImageIO.read(file);
                                                } catch (Exception e) {
                                                }
                                                SwingUtilities.invokeLater( new Runnable() {
                                                                public void run() {
                                                try {
                                                        image = ImageIO.read(file);
                                                } catch (Exception e) {
                                                }
                                                SwingUtilities.invokeLater( new Runnable() {
                                                                public void run() {
-                                                                       AltosSiteMap.debug_component(tile, "later");
+                                                                       AltosSiteMap.debug_component(tile, file.toString());
                                                                        Graphics2D g2d = (Graphics2D) tile.getGraphics();
                                                                        Graphics2D g2d = (Graphics2D) tile.getGraphics();
-                                                                       tile.paint_graphics(g2d, image);
+                                                                       if (g2d != null)
+                                                                               tile.paint_graphics(g2d, image, serial);
                                                                        load_thread = null;
                                                                }
                                                        });
                                                                        load_thread = null;
                                                                }
                                                        });