1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug #204881 : Deadlock between PathEntryManager and CProjectDescriptionManager

This commit is contained in:
Oleg Krasilnikov 2007-10-02 13:36:11 +00:00
parent 0ccfe513e0
commit d0c30f1b23
2 changed files with 16 additions and 14 deletions

View file

@ -1200,7 +1200,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
public void setPathEntryStore(IProject project, IPathEntryStore newStore) { public void setPathEntryStore(IProject project, IPathEntryStore newStore) {
IPathEntryStore oldStore = null; IPathEntryStore oldStore = null;
synchronized (this) { synchronized (storeMap) {
oldStore = (IPathEntryStore)storeMap.remove(project); oldStore = (IPathEntryStore)storeMap.remove(project);
if (newStore != null) { if (newStore != null) {
storeMap.put(project, newStore); storeMap.put(project, newStore);
@ -1213,18 +1213,20 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
} }
} }
public synchronized IPathEntryStore getPathEntryStore(IProject project, boolean create) throws CoreException { public IPathEntryStore getPathEntryStore(IProject project, boolean create) throws CoreException {
IPathEntryStore store = (IPathEntryStore)storeMap.get(project); synchronized (storeMap){
if (store == null) { IPathEntryStore store = (IPathEntryStore)storeMap.get(project);
if(create == true){ if (store == null) {
store = createPathEntryStore(project); if(create == true){
storeMap.put(project, store); store = createPathEntryStore(project);
store.addPathEntryStoreListener(this); storeMap.put(project, store);
store.addPathEntryStoreListener(this);
}
} else if (store instanceof AbstractCExtensionProxy){
((AbstractCExtensionProxy)store).updateProject(project);
} }
} else if (store instanceof AbstractCExtensionProxy){ return store;
((AbstractCExtensionProxy)store).updateProject(project);
} }
return store;
} }
public IPathEntryStore createPathEntryStore(IProject project) throws CoreException { public IPathEntryStore createPathEntryStore(IProject project) throws CoreException {

View file

@ -2807,13 +2807,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){ public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){
synchronized(this){ synchronized(fListeners){
fListeners.add(new ListenerDescriptor(listener, eventTypes)); fListeners.add(new ListenerDescriptor(listener, eventTypes));
} }
} }
public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){ public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){
synchronized(this){ synchronized(fListeners){
int size = fListeners.size(); int size = fListeners.size();
ListenerDescriptor des; ListenerDescriptor des;
for(int i = 0; i < size; i++){ for(int i = 0; i < size; i++){
@ -2827,7 +2827,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
} }
private ListenerDescriptor[] getListeners(){ private ListenerDescriptor[] getListeners(){
synchronized(this){ synchronized(fListeners){
return (ListenerDescriptor[])fListeners.toArray(new ListenerDescriptor[fListeners.size()]); return (ListenerDescriptor[])fListeners.toArray(new ListenerDescriptor[fListeners.size()]);
} }
} }