mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Fix for [Bug 185930] Exception when saving language mappings
This commit is contained in:
parent
67b1c89665
commit
d97e3a583f
10 changed files with 82 additions and 12 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems Ltd - initial API and implementation
|
* QNX Software Systems Ltd - initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems)
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.cdescriptor.tests;
|
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("testExtensionRemove"));
|
||||||
suite.addTest(new CDescriptorTests("testProjectDataCreate"));
|
suite.addTest(new CDescriptorTests("testProjectDataCreate"));
|
||||||
suite.addTest(new CDescriptorTests("testProjectDataDelete"));
|
suite.addTest(new CDescriptorTests("testProjectDataDelete"));
|
||||||
|
suite.addTest(new CDescriptorTests("testConcurrentDescriptorCreation"));
|
||||||
|
|
||||||
TestSetup wrapper = new TestSetup(suite) {
|
TestSetup wrapper = new TestSetup(suite) {
|
||||||
|
|
||||||
|
@ -146,6 +148,28 @@ public class CDescriptorTests extends TestCase {
|
||||||
Assert.assertEquals("*", desc.getPlatform());
|
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 {
|
public void testDescriptorOwner() throws Exception {
|
||||||
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
ICDescriptor desc = CCorePlugin.getDefault().getCProjectDescription(fProject, true);
|
||||||
ICOwnerInfo owner = desc.getProjectOwner();
|
ICOwnerInfo owner = desc.getProjectOwner();
|
||||||
|
@ -236,4 +260,5 @@ public class CDescriptorTests extends TestCase {
|
||||||
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
Assert.assertEquals(fLastEvent.getFlags(), 0);
|
||||||
fLastEvent = null;
|
fLastEvent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -109,9 +109,18 @@ public class XmlStorageElement implements ICStorageElement {
|
||||||
public ICStorageElement[] getChildren() {
|
public ICStorageElement[] getChildren() {
|
||||||
return getChildren(XmlStorageElement.class);
|
return getChildren(XmlStorageElement.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ICStorageElement[] getChildren(Class clazz){
|
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(
|
ICStorageElement[] children = (ICStorageElement[])java.lang.reflect.Array.newInstance(
|
||||||
clazz, fChildList.size());
|
clazz, fChildList.size());
|
||||||
|
|
|
@ -450,6 +450,7 @@ public class CConfigurationDescriptionCache extends CDefaultConfigurationData
|
||||||
void doneInitialization(){
|
void doneInitialization(){
|
||||||
CProjectDescriptionManager.getInstance().notifyCached(this, fData, null);
|
CProjectDescriptionManager.getInstance().notifyCached(this, fData, null);
|
||||||
fInitializing = false;
|
fInitializing = false;
|
||||||
|
fSpecSettings.doneInitialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExcludeStatus) {
|
public ICLanguageSetting getLanguageSettingForFile(IPath path, boolean ignoreExcludeStatus) {
|
||||||
|
|
|
@ -276,6 +276,17 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
|
||||||
return fStorage;
|
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(){
|
public String getBuildSystemId(){
|
||||||
return fBuildSystemId;
|
return fBuildSystemId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,11 +194,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doneInitializing();
|
// doneInitializing();
|
||||||
|
|
||||||
factory.clear();
|
factory.clear();
|
||||||
|
|
||||||
fIsLoadding = false;
|
// fIsLoadding = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyDatas(){
|
void applyDatas(){
|
||||||
|
@ -216,13 +216,25 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doneInitializing();
|
// doneInitializing();
|
||||||
|
|
||||||
factory.clear();
|
factory.clear();
|
||||||
|
|
||||||
fIsApplying = false;
|
// fIsApplying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void doneApplying(){
|
||||||
|
doneInitializing();
|
||||||
|
fIsApplying = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void doneLoadding(){
|
||||||
|
doneInitializing();
|
||||||
|
fIsLoadding = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void doneInitializing(){
|
private void doneInitializing(){
|
||||||
for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
|
for(Iterator iter = fCfgMap.values().iterator(); iter.hasNext();){
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
||||||
|
@ -420,7 +432,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
|
|
||||||
ICStorageElement getRootStorageElement() throws CoreException{
|
ICStorageElement getRootStorageElement() throws CoreException{
|
||||||
if(fRootStorageElement == null){
|
if(fRootStorageElement == null){
|
||||||
fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, fIsReadOnly);
|
fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, isReadOnly());
|
||||||
}
|
}
|
||||||
return fRootStorageElement;
|
return fRootStorageElement;
|
||||||
}
|
}
|
||||||
|
|
|
@ -576,6 +576,7 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
des = new CProjectDescription(des, true, el);
|
des = new CProjectDescription(des, true, el);
|
||||||
setDescriptionApplying(project, des);
|
setDescriptionApplying(project, des);
|
||||||
des.applyDatas();
|
des.applyDatas();
|
||||||
|
des.doneApplying();
|
||||||
clearDescriptionApplying(project);
|
clearDescriptionApplying(project);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -886,12 +887,13 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICProjectDescription loadProjectDescription(IProject project) throws CoreException{
|
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);
|
CProjectDescription des = new CProjectDescription(project, storage, true);
|
||||||
if(des != null){
|
if(des != null){
|
||||||
try {
|
try {
|
||||||
setDescriptionLoadding(project, des);
|
setDescriptionLoadding(project, des);
|
||||||
des.loadDatas();
|
des.loadDatas();
|
||||||
|
des.doneLoadding();
|
||||||
}finally{
|
}finally{
|
||||||
clearDescriptionLoadding(project);
|
clearDescriptionLoadding(project);
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,14 @@ public class CStorage implements ICSettingsStorage{
|
||||||
|
|
||||||
return false;
|
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){
|
public void setDirty(boolean isDirty){
|
||||||
fIsDirty = isDirty;
|
fIsDirty = isDirty;
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class InternalXmlStorageElement extends XmlStorageElement {
|
||||||
public void setReadOnly(boolean readOnly){
|
public void setReadOnly(boolean readOnly){
|
||||||
fIsReadOnly = readOnly;
|
fIsReadOnly = readOnly;
|
||||||
|
|
||||||
ICStorageElement children[] = getChildren();
|
ICStorageElement children[] = getChildren(false);
|
||||||
for(int i = 0; i < children.length; i++){
|
for(int i = 0; i < children.length; i++){
|
||||||
((InternalXmlStorageElement)children[i]).setReadOnly(readOnly);
|
((InternalXmlStorageElement)children[i]).setReadOnly(readOnly);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,8 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
|
||||||
} catch (CoreException e1) {
|
} catch (CoreException e1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fNewDescriptionCache.doneApplying();
|
||||||
|
|
||||||
event = mngr.createAppliedEvent(fNewDescriptionCache, fOldDescriptionCache, fSetDescription, delta);
|
event = mngr.createAppliedEvent(fNewDescriptionCache, fOldDescriptionCache, fSetDescription, delta);
|
||||||
mngr.notifyListeners(event);
|
mngr.notifyListeners(event);
|
||||||
|
|
||||||
|
|
|
@ -173,11 +173,11 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
|
||||||
dr.apply(true);
|
dr.apply(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICDescriptor getDescriptor(IProject project) throws CoreException {
|
public synchronized ICDescriptor getDescriptor(IProject project) throws CoreException {
|
||||||
return getDescriptor(project, true);
|
return getDescriptor(project, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICDescriptor getDescriptor(IProject project, boolean create)
|
public synchronized ICDescriptor getDescriptor(IProject project, boolean create)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
return findDescriptor(project, create);
|
return findDescriptor(project, create);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue