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:
parent
761bb3f471
commit
a881c07eec
2 changed files with 64 additions and 2 deletions
|
@ -19,6 +19,7 @@ import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CDescriptorEvent;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.core.ICExtension;
|
import org.eclipse.cdt.core.ICExtension;
|
||||||
import org.eclipse.cdt.core.ICExtensionReference;
|
import org.eclipse.cdt.core.ICExtensionReference;
|
||||||
|
@ -51,6 +52,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
private HashMap fStorageDataElMap = new HashMap();
|
private HashMap fStorageDataElMap = new HashMap();
|
||||||
private boolean fApplyOnChange = true;
|
private boolean fApplyOnChange = true;
|
||||||
private boolean fIsDirty;
|
private boolean fIsDirty;
|
||||||
|
private CDescriptorEvent fOpEvent;
|
||||||
|
private boolean fIsOpStarted;
|
||||||
|
|
||||||
class CConfigBaseDescriptorExtensionReference implements ICExtensionReference{
|
class CConfigBaseDescriptorExtensionReference implements ICExtensionReference{
|
||||||
private ICConfigExtensionReference fCfgExtRef;
|
private ICConfigExtensionReference fCfgExtRef;
|
||||||
|
@ -97,6 +100,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
fIsDirty = true;
|
fIsDirty = true;
|
||||||
fCfgExtRef.setExtensionData(key, value);
|
fCfgExtRef.setExtensionData(key, value);
|
||||||
checkApply();
|
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);
|
ICExtensionReference r = create(ref);
|
||||||
fIsDirty = true;
|
fIsDirty = true;
|
||||||
checkApply();
|
checkApply();
|
||||||
|
if(isOperationStarted())
|
||||||
|
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,6 +324,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
}
|
}
|
||||||
fIsDirty = true;
|
fIsDirty = true;
|
||||||
checkApply();
|
checkApply();
|
||||||
|
if(isOperationStarted())
|
||||||
|
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(String extensionPoint) throws CoreException {
|
public void remove(String extensionPoint) throws CoreException {
|
||||||
|
@ -336,6 +345,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
}
|
}
|
||||||
fIsDirty = true;
|
fIsDirty = true;
|
||||||
checkApply();
|
checkApply();
|
||||||
|
if(isOperationStarted())
|
||||||
|
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.EXTENSION_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveProjectData() throws CoreException {
|
public void saveProjectData() throws CoreException {
|
||||||
|
@ -343,6 +354,8 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
fIsDirty = true;
|
fIsDirty = true;
|
||||||
|
|
||||||
checkApply();
|
checkApply();
|
||||||
|
if(isOperationStarted())
|
||||||
|
setOpEvent(new CDescriptorEvent(this, CDescriptorEvent.CDTPROJECT_CHANGED, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getStorageDataElMap(){
|
public Map getStorageDataElMap(){
|
||||||
|
@ -352,4 +365,39 @@ public class CConfigBasedDescriptor implements ICDescriptor {
|
||||||
public ICConfigurationDescription getConfigurationDescription() {
|
public ICConfigurationDescription getConfigurationDescription() {
|
||||||
return fCfgDes;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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{
|
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 = updateDescriptor(project, dr, id);
|
||||||
dr.apply(true);
|
dr.apply(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(dr.isOperationStarted())
|
||||||
|
dr.setOpEvent(new CDescriptorEvent(dr, CDescriptorEvent.CDTPROJECT_CHANGED, CDescriptorEvent.OWNER_CHANGED));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICDescriptor getDescriptor(IProject project) throws CoreException {
|
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$
|
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()) {
|
synchronized (CProjectDescriptionManager.getInstance()) {
|
||||||
boolean initialApplyOnChange = dr.isApplyOnChange();
|
boolean initialApplyOnChange = dr.isApplyOnChange();
|
||||||
dr.setApplyOnChange(false);
|
dr.setApplyOnChange(false);
|
||||||
try {
|
try {
|
||||||
|
dr.operationStart();
|
||||||
op.execute(dr, monitor);
|
op.execute(dr, monitor);
|
||||||
} finally {
|
} finally {
|
||||||
|
event = dr.operationStop();
|
||||||
dr.setApplyOnChange(initialApplyOnChange);
|
dr.setApplyOnChange(initialApplyOnChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
dr.apply(false);
|
// dr.apply(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(event != null){
|
||||||
|
CConfigBasedDescriptorManager.getInstance().notifyListeners(event);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runDescriptorOperation(IProject project,
|
public void runDescriptorOperation(IProject project,
|
||||||
|
|
Loading…
Add table
Reference in a new issue