altosuilib: Serialize access to async tile notify function in preload
authorKeith Packard <keithp@keithp.com>
Sun, 15 Jun 2014 01:51:25 +0000 (18:51 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 15 Jun 2014 01:55:23 +0000 (18:55 -0700)
This ensures that we see each tile getting downloaded and don't
mis-count, which would result in wedging the process

Signed-off-by: Keith Packard <keithp@keithp.com>
altosuilib/AltosUIMapPreload.java
altosuilib/AltosUIMapView.java

index 3bdba39e723a6b0aebc63295b34568aa56152f67..c91b06b8b1e197fd42d3b14b3959a47655870ab6 100644 (file)
@@ -327,7 +327,7 @@ public class AltosUIMapPreload extends AltosUIFrame implements ActionListener, I
 
        /* AltosUIMapTileListener methods */
 
-       public void notify_tile(AltosUIMapTile tile, int status) {
+       public synchronized void notify_tile(AltosUIMapTile tile, int status) {
                if (status == AltosUIMapStore.loading)
                        return;
 
index 4df178e2e57e6ba676d0f619a30aedc0d6e2b0ce..a14fde6583e42cb64b938a49168dce22c751897f 100644 (file)
@@ -387,7 +387,7 @@ public class AltosUIMapView extends Component implements MouseMotionListener, Mo
        }
 
        /* AltosUIMapTileListener methods */
-       public void notify_tile(AltosUIMapTile tile, int status) {
+       public synchronized void notify_tile(AltosUIMapTile tile, int status) {
                for (Point point : tiles.keySet()) {
                        if (tile == tiles.get(point)) {
                                Point   screen = transform.screen(point);
@@ -399,7 +399,7 @@ public class AltosUIMapView extends Component implements MouseMotionListener, Mo
        public AltosUIMapCache cache() { return cache; }
 
        /* AltosUIMapStoreListener methods */
-       public void notify_store(AltosUIMapStore store, int status) {
+       public synchronized void notify_store(AltosUIMapStore store, int status) {
                if (load_listener != null) {
                        for (AltosUIMapTile tile : tiles.values())
                                if (store.equals(tile.store))