1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 16:56:04 +02:00

Fix for [Bug 185930] Exception when saving language mappings

This commit is contained in:
Mikhail Sennikovsky 2007-05-10 10:50:27 +00:00
parent 67b1c89665
commit d97e3a583f
10 changed files with 82 additions and 12 deletions

View file

@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (c) 2004, 2005 QNX Software Systems Ltd and others.
* Copyright (c) 2004, 2007 QNX Software Systems Ltd and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems Ltd - initial API and implementation
* Anton Leherbauer (Wind River Systems)
***********************************************************************/
package org.eclipse.cdt.core.cdescriptor.tests;
@ -68,6 +69,7 @@ public class CDescriptorTests extends TestCase {
suite.addTest(new CDescriptorTests("testExtensionRemove"));
suite.addTest(new CDescriptorTests("testProjectDataCreate"));
suite.addTest(new CDescriptorTests("testProjectDataDelete"));
suite.addTest(new CDescriptorTests("testConcurrentDescriptorCreation"));
TestSetup wrapper = new TestSetup(suite) {
@ -146,6 +148,28 @@ public class CDescriptorTests extends TestCase {
Assert.assertEquals("*", desc.getPlatform());
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=185930
public void testConcurrentDescriptorCreation() throws Exception {
fProject.close(null);
fProject.open(null);
Thread t= new Thread() {
public void run() {
try {
CCorePlugin.getDefault().getCProjectDescription(fProject, true);
} catch (CoreException exc) {
}
}
};
t.start();
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
t.join();
Element data = desc.getProjectData("testElement0");
data.appendChild(data.getOwnerDocument().createElement("test"));
desc.saveProjectData();
fLastEvent = null;
}
public void testDescriptorOwner() throws Exception {
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
ICOwnerInfo owner = desc.getProjectOwner();
@ -236,4 +260,5 @@ public class CDescriptorTests extends TestCase {
Assert.assertEquals(fLastEvent.getFlags(), 0);
fLastEvent = null;
}
}

View file

@ -109,9 +109,18 @@ public class XmlStorageElement implements ICStorageElement {
public ICStorageElement[] getChildren() {
return getChildren(XmlStorageElement.class);
}
protected ICStorageElement[] getChildren(Class clazz){
createChildren();
return getChildren(clazz, true);
}
protected ICStorageElement[] getChildren(boolean load){
return getChildren(XmlStorageElement.class, load);
}
protected ICStorageElement[] getChildren(Class clazz, boolean load){
if(load)
createChildren();
ICStorageElement[] children = (ICStorageElement[])java.lang.reflect.Array.newInstance(
clazz, fChildList.size());

View file

@ -450,6 +450,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
void doneInitialization(){
CProjectDescriptionManager.getInstance().notifyCached(this, fData, null);
fInitializing = false;
fSpecSettings.doneInitialization();
}
public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExcludeStatus) {

View file

@ -276,6 +276,17 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
return fStorage;
}
void doneInitialization(){
if(isReadOnly()){
if(fRootStorageElement != null)
((InternalXmlStorageElement)fRootStorageElement).setReadOnly(true);
if(fSettingsStorageElement != null)
((InternalXmlStorageElement)fSettingsStorageElement).setReadOnly(true);
if(fStorage != null)
fStorage.setReadOnly(true);
}
}
public String getBuildSystemId(){
return fBuildSystemId;
}

View file

@ -194,11 +194,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
}
doneInitializing();
// doneInitializing();
factory.clear();
fIsLoadding = false;
// fIsLoadding = false;
}
void applyDatas(){
@ -216,13 +216,25 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
}
doneInitializing();
// doneInitializing();
factory.clear();
fIsApplying = false;
// fIsApplying = false;
}
void doneApplying(){
doneInitializing();
fIsApplying = false;
}
void doneLoadding(){
doneInitializing();
fIsLoadding = false;
}
private void doneInitializing(){
for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
@ -420,7 +432,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
ICStorageElement getRootStorageElement() throws CoreException{
if(fRootStorageElement == null){
fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, fIsReadOnly);
fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, isReadOnly());
}
return fRootStorageElement;
}

View file

@ -576,6 +576,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
des = new CProjectDescription(des, true, el);
setDescriptionApplying(project, des);
des.applyDatas();
des.doneApplying();
clearDescriptionApplying(project);
try {
@ -886,12 +887,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
}
private ICProjectDescription loadProjectDescription(IProject project) throws CoreException{
ICStorageElement storage = CProjectDescriptionManager.getInstance().createStorage(project, true, false, true);
ICStorageElement storage = CProjectDescriptionManager.getInstance().createStorage(project, true, false, false);
CProjectDescription des = new CProjectDescription(project, storage, true);
if(des != null){
try {
setDescriptionLoadding(project, des);
des.loadDatas();
des.doneLoadding();
}finally{
clearDescriptionLoadding(project);
}

View file

@ -160,6 +160,14 @@ public class CStorage implements ICSettingsStorage{
return false;
}
void setReadOnly(boolean readOnly){
fIsReadOnly = readOnly;
for(Iterator iter = fStorageElementMap.values().iterator(); iter.hasNext();){
InternalXmlStorageElement el = (InternalXmlStorageElement)iter.next();
el.setReadOnly(readOnly);
}
}
public void setDirty(boolean isDirty){
fIsDirty = isDirty;

View file

@ -63,7 +63,7 @@ public class InternalXmlStorageElement extends XmlStorageElement {
public void setReadOnly(boolean readOnly){
fIsReadOnly = readOnly;
ICStorageElement children[] = getChildren();
ICStorageElement children[] = getChildren(false);
for(int i = 0; i < children.length; i++){
((InternalXmlStorageElement)children[i]).setReadOnly(readOnly);
}

View file

@ -109,6 +109,8 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
} catch (CoreException e1) {
}
fNewDescriptionCache.doneApplying();
event = mngr.createAppliedEvent(fNewDescriptionCache, fOldDescriptionCache, fSetDescription, delta);
mngr.notifyListeners(event);

View file

@ -173,11 +173,11 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
dr.apply(true);
}
public ICDescriptor getDescriptor(IProject project) throws CoreException {
public synchronized ICDescriptor getDescriptor(IProject project) throws CoreException {
return getDescriptor(project, true);
}
public ICDescriptor getDescriptor(IProject project, boolean create)
public synchronized ICDescriptor getDescriptor(IProject project, boolean create)
throws CoreException {
return findDescriptor(project, create);
}