mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-02 05:03:36 +02:00
Make sure to run the PathEntryContainerInitializer.initialize()
once. * model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
This commit is contained in:
parent
e8e773e868
commit
8e45e1973c
2 changed files with 64 additions and 31 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-06-09 Alain Magloire
|
||||||
|
|
||||||
|
Make sure to run the PathEntryContainerInitializer.initialize()
|
||||||
|
once.
|
||||||
|
* model/org/eclipse/cdt/internal/core/model/PathEntryManager.java
|
||||||
|
|
||||||
2004-06-09 Hoda Amer
|
2004-06-09 Hoda Amer
|
||||||
Fix for PR 62656 : [Saving] a cpp file after copying/renaming a function in front of a constructor locks Eclipse
|
Fix for PR 62656 : [Saving] a cpp file after copying/renaming a function in front of a constructor locks Eclipse
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,16 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
|
|
||||||
private class PathEntryContainerLock implements IPathEntryContainer {
|
private class PathEntryContainerLock implements IPathEntryContainer {
|
||||||
|
|
||||||
|
boolean runInitializer;
|
||||||
|
|
||||||
|
public boolean isContainerInitialize() {
|
||||||
|
return runInitializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContainerInitialize(boolean init) {
|
||||||
|
runInitializer = init;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
|
* @see org.eclipse.cdt.core.model.IPathEntryContainer#getPathEntries()
|
||||||
*/
|
*/
|
||||||
|
@ -113,8 +123,8 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
public IPath getPath() {
|
public IPath getPath() {
|
||||||
return Path.EMPTY;
|
return Path.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the singleton.
|
* Return the singleton.
|
||||||
*/
|
*/
|
||||||
|
@ -504,9 +514,24 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
// Try the cache.
|
// Try the cache.
|
||||||
IPathEntryContainer container = containerGet(project, containerPath);
|
IPathEntryContainer container = containerGet(project, containerPath);
|
||||||
if (container instanceof PathEntryContainerLock) {
|
if (container instanceof PathEntryContainerLock) {
|
||||||
synchronized(container) {
|
boolean runInitializer = false;
|
||||||
IPathEntryContainer newContainer = containerGet(project, containerPath);
|
PathEntryContainerLock lock = (PathEntryContainerLock)container;
|
||||||
if (newContainer == container) {
|
synchronized(lock) {
|
||||||
|
if (!lock.isContainerInitialize()) {
|
||||||
|
runInitializer = true;
|
||||||
|
lock.setContainerInitialize(runInitializer);
|
||||||
|
} else {
|
||||||
|
// Wait for the inialization to finish.
|
||||||
|
while(containerGet(project, containerPath) instanceof PathEntryContainerLock) {
|
||||||
|
try {
|
||||||
|
lock.wait();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (runInitializer) {
|
||||||
// remove the lock.
|
// remove the lock.
|
||||||
final PathEntryContainerInitializer initializer = getPathEntryContainerInitializer(containerPath.segment(0));
|
final PathEntryContainerInitializer initializer = getPathEntryContainerInitializer(containerPath.segment(0));
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
|
@ -527,16 +552,13 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
initializer.initialize(containerPath, project);
|
initializer.initialize(containerPath, project);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// retrieve value (if initialization was successful)
|
|
||||||
container = containerGet(project, containerPath);
|
|
||||||
if (!ok[0]) {
|
if (!ok[0]) {
|
||||||
containerPut(project, containerPath, null); // flush
|
containerPut(project, containerPath, null); // flush and notify
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
container = newContainer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// retrieve new value
|
||||||
|
container = containerGet(project, containerPath);
|
||||||
}
|
}
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
@ -601,7 +623,12 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
||||||
projectContainers = new HashMap();
|
projectContainers = new HashMap();
|
||||||
Containers.put(cproject, projectContainers);
|
Containers.put(cproject, projectContainers);
|
||||||
}
|
}
|
||||||
projectContainers.put(containerPath, container);
|
IPathEntryContainer oldContainer = (IPathEntryContainer)projectContainers.put(containerPath, container);
|
||||||
|
if (oldContainer instanceof PathEntryContainerLock) {
|
||||||
|
synchronized (oldContainer) {
|
||||||
|
oldContainer.notifyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void containerRemove(ICProject cproject) {
|
private synchronized void containerRemove(ICProject cproject) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue