mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 211423: TextFileBufferManager failed to notify an ITextFileBufferListener
This commit is contained in:
parent
f61f0b09a6
commit
88a3de11fd
1 changed files with 35 additions and 26 deletions
|
@ -26,6 +26,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.ListenerList;
|
||||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
@ -626,8 +627,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object getAnnotations(Position position) {
|
private Object getAnnotations(Position position) {
|
||||||
|
synchronized (getLockObject()) {
|
||||||
return fReverseMap.get(position);
|
return fReverseMap.get(position);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
|
* @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
|
||||||
|
@ -635,6 +638,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
|
protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
|
||||||
super.addAnnotation(annotation, position, fireModelChanged);
|
super.addAnnotation(annotation, position, fireModelChanged);
|
||||||
|
|
||||||
|
synchronized (getLockObject()) {
|
||||||
Object cached= fReverseMap.get(position);
|
Object cached= fReverseMap.get(position);
|
||||||
if (cached == null)
|
if (cached == null)
|
||||||
fReverseMap.put(position, annotation);
|
fReverseMap.put(position, annotation);
|
||||||
|
@ -648,20 +652,24 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
fReverseMap.put(position, list);
|
fReverseMap.put(position, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see AnnotationModel#removeAllAnnotations(boolean)
|
* @see AnnotationModel#removeAllAnnotations(boolean)
|
||||||
*/
|
*/
|
||||||
protected void removeAllAnnotations(boolean fireModelChanged) {
|
protected void removeAllAnnotations(boolean fireModelChanged) {
|
||||||
super.removeAllAnnotations(fireModelChanged);
|
super.removeAllAnnotations(fireModelChanged);
|
||||||
|
synchronized (getLockObject()) {
|
||||||
fReverseMap.clear();
|
fReverseMap.clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see AnnotationModel#removeAnnotation(Annotation, boolean)
|
* @see AnnotationModel#removeAnnotation(Annotation, boolean)
|
||||||
*/
|
*/
|
||||||
protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
|
protected void removeAnnotation(Annotation annotation, boolean fireModelChanged) {
|
||||||
Position position= getPosition(annotation);
|
Position position= getPosition(annotation);
|
||||||
|
synchronized (getLockObject()) {
|
||||||
Object cached= fReverseMap.get(position);
|
Object cached= fReverseMap.get(position);
|
||||||
if (cached instanceof List) {
|
if (cached instanceof List) {
|
||||||
List list= (List) cached;
|
List list= (List) cached;
|
||||||
|
@ -673,23 +681,24 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
} else if (cached instanceof Annotation) {
|
} else if (cached instanceof Annotation) {
|
||||||
fReverseMap.remove(position);
|
fReverseMap.remove(position);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
super.removeAnnotation(annotation, fireModelChanged);
|
super.removeAnnotation(annotation, fireModelChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
|
protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
|
||||||
|
|
||||||
private ArrayList fListenerList;
|
private ListenerList fListenerList;
|
||||||
|
|
||||||
public GlobalAnnotationModelListener() {
|
public GlobalAnnotationModelListener() {
|
||||||
fListenerList= new ArrayList();
|
fListenerList= new ListenerList(ListenerList.IDENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see IAnnotationModelListener#modelChanged(IAnnotationModel)
|
* @see IAnnotationModelListener#modelChanged(IAnnotationModel)
|
||||||
*/
|
*/
|
||||||
public void modelChanged(IAnnotationModel model) {
|
public void modelChanged(IAnnotationModel model) {
|
||||||
Object[] listeners= fListenerList.toArray();
|
Object[] listeners= fListenerList.getListeners();
|
||||||
for (int i= 0; i < listeners.length; i++) {
|
for (int i= 0; i < listeners.length; i++) {
|
||||||
((IAnnotationModelListener) listeners[i]).modelChanged(model);
|
((IAnnotationModelListener) listeners[i]).modelChanged(model);
|
||||||
}
|
}
|
||||||
|
@ -699,7 +708,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
|
* @see IAnnotationModelListenerExtension#modelChanged(AnnotationModelEvent)
|
||||||
*/
|
*/
|
||||||
public void modelChanged(AnnotationModelEvent event) {
|
public void modelChanged(AnnotationModelEvent event) {
|
||||||
Object[] listeners= fListenerList.toArray();
|
Object[] listeners= fListenerList.getListeners();
|
||||||
for (int i= 0; i < listeners.length; i++) {
|
for (int i= 0; i < listeners.length; i++) {
|
||||||
Object curr= listeners[i];
|
Object curr= listeners[i];
|
||||||
if (curr instanceof IAnnotationModelListenerExtension) {
|
if (curr instanceof IAnnotationModelListenerExtension) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue