mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
data race
This commit is contained in:
@@ -27,7 +27,8 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.WeakList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Date: Mar 17, 2009
|
||||
@@ -39,14 +40,16 @@ public class LazyRangeMarkerFactory extends AbstractProjectComponent {
|
||||
super(project);
|
||||
EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new DocumentAdapter() {
|
||||
public void beforeDocumentChange(DocumentEvent e) {
|
||||
for (Iterator<LazyMarker> it = myMarkers.iterator(); it.hasNext();) {
|
||||
final LazyMarker marker = it.next();
|
||||
List<LazyMarker> markers = myMarkers.toStrongList();
|
||||
List<LazyMarker> markersToRemove = new ArrayList<LazyMarker>();
|
||||
for (final LazyMarker marker : markers) {
|
||||
final VirtualFile docFile = fileDocumentManager.getFile(e.getDocument());
|
||||
if (marker.getFile() == docFile) {
|
||||
marker.ensureDelegate();
|
||||
it.remove();
|
||||
markersToRemove.add(marker);
|
||||
}
|
||||
}
|
||||
myMarkers.removeAll(markersToRemove);
|
||||
}
|
||||
}, project);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,13 @@ public class WeakList<T> extends AbstractList<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
synchronized (myArray) {
|
||||
return super.removeAll(c);
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<T> iterator() {
|
||||
return new MyIterator();
|
||||
}
|
||||
@@ -88,7 +95,7 @@ public class WeakList<T> extends AbstractList<T> {
|
||||
|
||||
public List<T> toStrongList() {
|
||||
synchronized (myArray) {
|
||||
List<T> result = new ArrayList<T>();
|
||||
List<T> result = new ArrayList<T>(myArray.size());
|
||||
myArray.toStrongCollection(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user