Changeset 2471 in josm


Ignore:
Timestamp:
2009-11-18T18:50:38+01:00 (12 years ago)
Author:
Gubaer
Message:

fixed #3963: Synchronize does not work

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java

    r2444 r2471  
    1010import java.util.Collection;
    1111import java.util.Collections;
     12import java.util.logging.Logger;
    1213
    1314import javax.swing.JOptionPane;
     
    138139     */
    139140    static class UpdatePrimitivesTask extends PleaseWaitRunnable {
     141        static private final Logger logger = Logger.getLogger(UpdatePrimitivesTask.class.getName());
     142
    140143        private DataSet ds;
    141144        private boolean canceled;
     
    144147        private MultiFetchServerObjectReader reader;
    145148
     149        /**
     150         *
     151         * @param toUpdate a collection of primitives to update from the server
     152         */
    146153        public UpdatePrimitivesTask(Collection<? extends OsmPrimitive> toUpdate) {
    147154            super(tr("Update objects"), false /* don't ignore exception*/);
     
    166173                return;
    167174            }
    168             if (ds != null) {
    169                 Main.map.mapView.getEditLayer().mergeFrom(ds);
    170                 Main.map.mapView.getEditLayer().onPostDownloadFromServer();
     175            if (ds != null && Main.main.getEditLayer() != null) {
     176                Main.main.getEditLayer().mergeFrom(ds);
     177                Main.main.getEditLayer().onPostDownloadFromServer();
    171178            }
    172179        }
     
    202209            }
    203210        }
     211
    204212
    205213        @Override
  • trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java

    r2444 r2471  
    8383            if (mergeById(source))
    8484                return;
    85             if (!source.isVisible())
    86                 // ignore it
    87                 return;
     85            //if (!source.isVisible())
     86            // ignore it
     87            //    return;
    8888        } else {
    8989            // try to merge onto a primitive  which has no id assigned
     
    236236     * Tries to merge a primitive <code>source</code> into an existing primitive with the same id.
    237237     *
    238      * @param source  the other primitive which is to be merged onto a primitive in my primitives
     238     * @param source  the source primitive which is to be merged into a target primitive
    239239     * @return true, if this method was able to merge <code>source</code> into a target object; false, otherwise
    240240     */
  • trunk/src/org/openstreetmap/josm/data/osm/User.java

    r2455 r2471  
    77import java.util.HashMap;
    88import java.util.List;
     9import java.util.concurrent.atomic.AtomicLong;
    910
    1011/**
     
    1819 */
    1920public class User {
    20     static private long uidCounter = 0;
     21
     22    static private AtomicLong uidCounter = new AtomicLong();
     23
    2124    /**
    2225     * the map of known users
     
    2730    private static long getNextLocalUid() {
    2831        synchronized(User.class) {
    29             uidCounter--;
    30             return uidCounter;
     32            return uidCounter.decrementAndGet();
    3133        }
    3234    }
     
    6062    }
    6163
     64    /**
     65     * clears the static map of user ids to user objects
     66     *
     67     */
     68    public static void clearUserMap() {
     69        userMap.clear();
     70    }
    6271
    6372    /**
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r2443 r2471  
    1717import java.util.logging.Logger;
    1818
     19import org.junit.Before;
    1920import org.junit.BeforeClass;
    2021import org.junit.Test;
     
    6263    }
    6364
     65    @Before
     66    public void setUp() {
     67        User.clearUserMap();
     68    }
     69
    6470    /**
    6571     * two identical nodes, even in id and version. No confict expected.
     
    348354    /**
    349355     * their node is not visible and doesn't exist in my data set
    350      * => ignore their node
     356     * => we can't ignore it because we'd run into troubles in case of multi fetch
     357     * which can return invisible objects
    351358     *
    352359     */
     
    373380        Node n2 = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE);
    374381        assertEquals(0,visitor.getConflicts().size());
    375         assertEquals(1, my.getNodes().size());
     382        assertEquals(2, my.getNodes().size());
    376383        assertEquals(n,n2);
    377384    }
     
    775782        theirWay.addNode(n3);
    776783        theirWay.addNode(n4);
    777         theirWay.setUser(User.createOsmUser(1111, "their"));
     784        User user = User.createOsmUser(1111, "their");
     785        theirWay.setUser(user);
    778786        theirWay.setTimestamp(new Date());
    779787        their.addPrimitive(theirWay);
     
    895903        theirWay.addNode(n4);
    896904        theirWay.addNode(n5);
    897         theirWay.setUser(User.createOsmUser(1111, "their"));
     905        User user = User.getById(1111);
     906        if (user == null) {
     907            User.createOsmUser(1111, "their");
     908        }
     909        theirWay.setUser(user);
    898910        theirWay.setTimestamp(new Date());
    899911        their.addPrimitive(theirWay);
     
    10811093        assertTrue(!w.getNode(1).incomplete);
    10821094    }
     1095
    10831096}
Note: See TracChangeset for help on using the changeset viewer.