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

Fix for [Bug 201254] [Project Model] occasional deadlocks

This commit is contained in:
Mikhail Sennikovsky 2007-08-30 15:57:19 +00:00
parent 761bb3f471
commit a881c07eec
2 changed files with 64 additions and 2 deletions

View file

@ -19,6 +19,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.cdt.core.CDescriptorEvent;
import org.eclipse.cdt.core.ICDescriptor;
import org.eclipse.cdt.core.ICExtension;
import org.eclipse.cdt.core.ICExtensionReference;
@ -43,7 +44,7 @@ import org.w3c.dom.Element;
public class CConfigBasedDescriptor implements ICDescriptor {
private static final String CEXTENSION_NAME = "cextension"; //$NON-NLS-1$
private ICConfigurationDescription fCfgDes;
private IProject fProject;
private COwner fOwner;
@ -51,6 +52,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
private HashMap fStorageDataElMap = new HashMap();
private boolean fApplyOnChange = true;
private boolean fIsDirty;
private CDescriptorEvent fOpEvent;
private boolean fIsOpStarted;
class CConfigBaseDescriptorExtensionReference implements ICExtensionReference{
private ICConfigExtensionReference fCfgExtRef;
@ -97,6 +100,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
fIsDirty = true;
fCfgExtRef.setExtensionData(key, value);
checkApply();
if(isOperationStarted())
setOpEvent(new CDescriptorEvent(CConfigBasedDescriptor.this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
}
}
}
@ -159,6 +164,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
ICExtensionReference r = create(ref);
fIsDirty = true;
checkApply();
if(isOperationStarted())
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
return r;
}
@ -317,6 +324,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
}
fIsDirty = true;
checkApply();
if(isOperationStarted())
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
}
public void remove(String extensionPoint) throws CoreException {
@ -336,6 +345,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
}
fIsDirty = true;
checkApply();
if(isOperationStarted())
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
}
public void saveProjectData() throws CoreException {
@ -343,6 +354,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
fIsDirty = true;
checkApply();
if(isOperationStarted())
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
}
public Map getStorageDataElMap(){
@ -352,4 +365,39 @@ public class CConfigBasedDescriptor implements ICDescriptor {
public ICConfigurationDescription getConfigurationDescription() {
return fCfgDes;
}
void setOpEvent(CDescriptorEvent event) {
if(!isOperationStarted())
return;
if (event.getType() == CDescriptorEvent.CDTPROJECT_ADDED) {
fOpEvent = event;
} else if (event.getType() == CDescriptorEvent.CDTPROJECT_REMOVED) {
fOpEvent = event;
} else {
if (fOpEvent == null) {
fOpEvent = event;
} else if ( (fOpEvent.getFlags() & event.getFlags()) != event.getFlags()) {
fOpEvent = new CDescriptorEvent(event.getDescriptor(), event.getType(),
fOpEvent.getFlags() | event.getFlags());
}
}
}
boolean isOperationStarted(){
return fIsOpStarted;
}
void operationStart(){
fIsOpStarted = true;
}
CDescriptorEvent operationStop(){
fIsOpStarted = false;
CDescriptorEvent e = fOpEvent;
fOpEvent = null;
return e;
}
}

View file

@ -143,6 +143,9 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
// }
}
}
if(dr.isOperationStarted())
dr.setOpEvent(new CDescriptorEvent(dr, CDescriptorEvent.CDTPROJECT_ADDED, 0));
}
private CConfigBasedDescriptor updateDescriptor(IProject project, CConfigBasedDescriptor dr, String ownerId) throws CoreException{
@ -182,6 +185,9 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
dr = updateDescriptor(project, dr, id);
dr.apply(true);
}
if(dr.isOperationStarted())
dr.setOpEvent(new CDescriptorEvent(dr, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
}
public ICDescriptor getDescriptor(IProject project) throws CoreException {
@ -211,17 +217,25 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, -1, "Failed to create descriptor", null)); //$NON-NLS-1$
}
CDescriptorEvent event = null;
synchronized (CProjectDescriptionManager.getInstance()) {
boolean initialApplyOnChange = dr.isApplyOnChange();
dr.setApplyOnChange(false);
try {
dr.operationStart();
op.execute(dr, monitor);
} finally {
event = dr.operationStop();
dr.setApplyOnChange(initialApplyOnChange);
}
dr.apply(false);
// dr.apply(false);
}
if(event != null){
CConfigBasedDescriptorManager.getInstance().notifyListeners(event);
}
}
public void runDescriptorOperation(IProject project,