Ticket #10920: GeoImageLayer_stopLoadThumbs.patch
File GeoImageLayer_stopLoadThumbs.patch, 3.0 KB (added by , 9 years ago) |
---|
-
src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
372 372 public void mergeFrom(Layer from) { 373 373 GeoImageLayer l = (GeoImageLayer) from; 374 374 375 // Stop to load thumbnails on both layers. Thumbnail loading will continue the next time 376 // the layer is painted. 377 stopLoadThumbs(); 378 l.stopLoadThumbs(); 379 375 380 ImageEntry selected = null; 376 381 if (l.currentPhoto >= 0) { 377 382 selected = l.data.get(l.currentPhoto); … … 988 993 @Override 989 994 public void layerRemoved(Layer oldLayer) { 990 995 if (oldLayer == GeoImageLayer.this) { 991 if (thumbsloader != null) { 992 thumbsloader.stop = true; 993 } 996 stopLoadThumbs(); 994 997 Main.map.mapView.removeMouseListener(mouseAdapter); 995 998 MapFrame.removeMapModeChangeListener(mapModeListener); 996 999 currentPhoto = -1; … … 1018 1021 1019 1022 public void loadThumbs() { 1020 1023 if (useThumbs && !thumbsLoaded) { 1024 stopLoadThumbs(); 1021 1025 thumbsLoaded = true; 1022 1026 thumbsloader = new ThumbsLoader(this); 1023 1027 Thread t = new Thread(thumbsloader); … … 1026 1030 } 1027 1031 } 1028 1032 1033 /** 1034 * Stop to load thumbnails. Can be called at any time to make sure that the 1035 * thumbnail loader is stopped. 1036 * @since tbd 1037 */ 1038 public void stopLoadThumbs() { 1039 if (thumbsloader != null) { 1040 thumbsloader.stop = true; 1041 if (!thumbsloader.done) { 1042 thumbsLoaded = false; 1043 } 1044 } 1045 } 1046 1029 1047 public void updateBufferAndRepaint() { 1030 1048 updateOffscreenBuffer = true; 1031 1049 Main.map.mapView.repaint(); … … 1076 1094 this.useThumbs = useThumbs; 1077 1095 if (useThumbs && !thumbsLoaded) { 1078 1096 loadThumbs(); 1097 } else if (!useThumbs) { 1098 stopLoadThumbs(); 1079 1099 } 1080 1100 } 1081 1101 } -
src/org/openstreetmap/josm/gui/layer/geoimage/ThumbsLoader.java
16 16 public class ThumbsLoader implements Runnable { 17 17 public static final int maxSize = 120; 18 18 public static final int minSize = 22; 19 volatile boolean stop = false; 19 public volatile boolean stop = false; 20 public volatile boolean done = false; 20 21 List<ImageEntry> data; 21 22 GeoImageLayer layer; 22 23 MediaTracker tracker; … … 50 51 } 51 52 } 52 53 } 54 done = true; 53 55 layer.updateOffscreenBuffer = true; 54 56 Main.map.mapView.repaint(); 55 57 }