Changeset 2896 in josm


Ignore:
Timestamp:
2010-01-27T20:49:59+01:00 (15 years ago)
Author:
jttt
Message:

Fixed #4057 JOSM loses data on save: Approx 20% data loss of ways but none of nodes/relations

File:
1 edited

Legend:

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

    r2868 r2896  
    1515public class QuadBuckets<T extends OsmPrimitive> implements Collection<T>
    1616{
    17     public static boolean debug = false;
    18     static boolean consistency_testing = false;
     17    private static boolean debug = false;
     18    private static final boolean consistency_testing = false;
    1919    /*
    2020     * Functions prefixed with __ need locking before
    2121     * being called.
    2222     */
    23     private Object split_lock = new Object();
     23    private final Object split_lock = new Object();
    2424
    2525    static void abort(String s)
     
    7575            init(parent);
    7676        }
    77         synchronized boolean remove_content(T o)
    78         {
    79             boolean ret = this.content.remove(o);
    80             if (this.content.size() == 0) {
    81                 this.content = null;
    82             }
    83             if (this.canRemove()) {
    84                 this.remove_from_parent();
    85             }
    86             return ret;
     77        boolean remove_content(T o)
     78        {
     79            synchronized (split_lock) {
     80                // If two threads try to remove item at the same time from different buckets of this QBLevel,
     81                // it might happen that one thread removes bucket but don't remove parent because it still sees
     82                // another bucket set. Second thread do the same. Due to thread memory caching, it's possible that
     83                // changes made by threads will show up in children array too late, leading to QBLevel with all children
     84                // set to null
     85                boolean ret = this.content.remove(o);
     86                if (this.content.size() == 0) {
     87                    this.content = null;
     88                }
     89                if (this.canRemove()) {
     90                    this.remove_from_parent();
     91                }
     92                return ret;
     93            }
    8794        }
    8895        QBLevel[] newChildren()
Note: See TracChangeset for help on using the changeset viewer.