Changeset 3458 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2010-08-23T15:05:06+02:00 (14 years ago)
Author:
bastiK
Message:

fixed #5365 - Deadlock when using tracer plugin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r3457 r3458  
    431431     */
    432432    public void setSelected(Collection<? extends PrimitiveId> selection, boolean fireSelectionChangeEvent) {
    433         boolean wasEmpty;
     433        boolean changed;
    434434        synchronized (selectionLock) {
    435             wasEmpty = selectedPrimitives.isEmpty();
     435            boolean wasEmpty = selectedPrimitives.isEmpty();
    436436            selectedPrimitives = new LinkedHashSet<OsmPrimitive>();
    437             addSelected(selection, fireSelectionChangeEvent);
    438             if (!wasEmpty && selectedPrimitives.isEmpty()) {
     437            changed = addSelected(selection, false)
     438                            || (!wasEmpty && selectedPrimitives.isEmpty());
     439            if (changed) {
    439440                selectionSnapshot = null;
    440441            }
    441442        }
    442443
    443         if (!wasEmpty && selectedPrimitives.isEmpty() && fireSelectionChangeEvent) {
     444        if (changed && fireSelectionChangeEvent) {
    444445            // If selection is not empty then event was already fired in addSelecteds
    445446            fireSelectionChanged();
     
    486487     * @param selection the selection
    487488     * @param fireSelectionChangeEvent true, if the selection change listeners are to be notified; false, otherwise
    488      */
    489     public void addSelected(Collection<? extends PrimitiveId> selection, boolean fireSelectionChangeEvent) {
     489     * @return if the selection was changed in the process
     490     */
     491    private boolean addSelected(Collection<? extends PrimitiveId> selection, boolean fireSelectionChangeEvent) {
    490492        boolean changed = false;
    491493        synchronized (selectionLock) {
     
    503505            fireSelectionChanged();
    504506        }
     507        return changed;
    505508    }
    506509
Note: See TracChangeset for help on using the changeset viewer.