Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2007-12-07 07:41:49 -0500
committerAnton Leherbauer2007-12-07 07:41:49 -0500
commitd295a9834f48d5882b21142236933ecb784d3f26 (patch)
tree5995d926427b67512130368292de4394b59830bf
parent2ab2cd05f4bdb7ea256c3558dd72c3206c0d28a8 (diff)
downloadorg.eclipse.cdt-d295a9834f48d5882b21142236933ecb784d3f26.tar.gz
org.eclipse.cdt-d295a9834f48d5882b21142236933ecb784d3f26.tar.xz
org.eclipse.cdt-d295a9834f48d5882b21142236933ecb784d3f26.zip
Fix for 211423: TextFileBufferManager failed to notify an ITextFileBufferListener
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java61
1 files changed, 35 insertions, 26 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
index 417a9bef8a..bdae5d0cdb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CDocumentProvider.java
@@ -25,6 +25,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
@@ -613,7 +614,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
}
private Object getAnnotations(Position position) {
- return fReverseMap.get(position);
+ synchronized (getLockObject()) {
+ return fReverseMap.get(position);
+ }
}
/*
@@ -622,17 +625,19 @@ public class CDocumentProvider extends TextFileDocumentProvider {
protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
super.addAnnotation(annotation, position, fireModelChanged);
- Object cached= fReverseMap.get(position);
- if (cached == null)
- fReverseMap.put(position, annotation);
- else if (cached instanceof List) {
- List list= (List) cached;
- list.add(annotation);
- } else if (cached instanceof Annotation) {
- List list= new ArrayList(2);
- list.add(cached);
- list.add(annotation);
- fReverseMap.put(position, list);
+ synchronized (getLockObject()) {
+ Object cached= fReverseMap.get(position);
+ if (cached == null)
+ fReverseMap.put(position, annotation);
+ else if (cached instanceof List) {
+ List list= (List) cached;
+ list.add(annotation);
+ } else if (cached instanceof Annotation) {
+ List list= new ArrayList(2);
+ list.add(cached);
+ list.add(annotation);
+ fReverseMap.put(position, list);
+ }
}
}
@@ -641,7 +646,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/
protected void removeAllAnnotations(boolean fireModelChanged) {
super.removeAllAnnotations(fireModelChanged);
- fReverseMap.clear();
+ synchronized (getLockObject()) {
+ fReverseMap.clear();
+ }
}
/*
@@ -649,16 +656,18 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/
protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
Position position= getPosition(annotation);
- Object cached= fReverseMap.get(position);
- if (cached instanceof List) {
- List list= (List) cached;
- list.remove(annotation);
- if (list.size() == 1) {
- fReverseMap.put(position, list.get(0));
- list.clear();
+ synchronized (getLockObject()) {
+ Object cached= fReverseMap.get(position);
+ if (cached instanceof List) {
+ List list= (List) cached;
+ list.remove(annotation);
+ if (list.size() == 1) {
+ fReverseMap.put(position, list.get(0));
+ list.clear();
+ }
+ } else if (cached instanceof Annotation) {
+ fReverseMap.remove(position);
}
- } else if (cached instanceof Annotation) {
- fReverseMap.remove(position);
}
super.removeAnnotation(annotation, fireModelChanged);
}
@@ -666,17 +675,17 @@ public class CDocumentProvider extends TextFileDocumentProvider {
protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
- private ArrayList fListenerList;
+ private ListenerList fListenerList;
public GlobalAnnotationModelListener() {
- fListenerList= new ArrayList();
+ fListenerList= new ListenerList(ListenerList.IDENTITY);
}
/**
* @see IAnnotationModelListener#modelChanged(IAnnotationModel)
*/
public void modelChanged(IAnnotationModel model) {
- Object[] listeners= fListenerList.toArray();
+ Object[] listeners= fListenerList.getListeners();
for (int i= 0; i < listeners.length; i++) {
((IAnnotationModelListener) listeners[i]).modelChanged(model);
}
@@ -686,7 +695,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
* @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
*/
public void modelChanged(AnnotationModelEvent event) {
- Object[] listeners= fListenerList.toArray();
+ Object[] listeners= fListenerList.getListeners();
for (int i= 0; i < listeners.length; i++) {
Object curr= listeners[i];
if (curr instanceof IAnnotationModelListenerExtension) {

Back to the top