mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 349564 - The 'Binaries' node does not always disappear when project is cleaned
Change-Id: I511582a66f4b63b15732512093f30da08fa13ed4 Signed-off-by: Anton Leherbauer <anton.leherbauer@windriver.com>
This commit is contained in:
parent
2c56fe5406
commit
ce8be9513d
3 changed files with 98 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
* Copyright (c) 2000, 2015 QNX Software Systems 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
|
||||||
|
@ -43,6 +43,7 @@ import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IWorkspace;
|
import org.eclipse.core.resources.IWorkspace;
|
||||||
import org.eclipse.core.resources.IWorkspaceDescription;
|
import org.eclipse.core.resources.IWorkspaceDescription;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
@ -573,4 +574,80 @@ public class CModelTests extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testBinaryContainerDeltaAfterCloseProjDeleteBin_349564() throws Exception {
|
||||||
|
ICProject testProject;
|
||||||
|
testProject = CProjectHelper.createCProject("bug349564", "none", IPDOMManager.ID_NO_INDEXER);
|
||||||
|
if (testProject == null) {
|
||||||
|
fail("Unable to create project");
|
||||||
|
}
|
||||||
|
CProjectHelper.addDefaultBinaryParser(testProject.getProject());
|
||||||
|
|
||||||
|
final IBinaryContainer bin = testProject.getBinaryContainer();
|
||||||
|
assertEquals(0, bin.getBinaries().length);
|
||||||
|
// import with folder structure
|
||||||
|
importSourcesFromPlugin(testProject, CTestPlugin.getDefault().getBundle(), "resources/exe/x86/o");
|
||||||
|
assertEquals(1, bin.getBinaries().length);
|
||||||
|
IResource resource = bin.getBinaries()[0].getResource();
|
||||||
|
|
||||||
|
final boolean binContainerChanged[] = { false };
|
||||||
|
|
||||||
|
IElementChangedListener elementChangedListener = new IElementChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void elementChanged(ElementChangedEvent event) {
|
||||||
|
ICElementDelta delta = event.getDelta();
|
||||||
|
processDelta(delta);
|
||||||
|
}
|
||||||
|
private boolean processDelta(ICElementDelta delta) {
|
||||||
|
if (delta.getElement() instanceof IBinaryContainer) {
|
||||||
|
synchronized (binContainerChanged) {
|
||||||
|
binContainerChanged[0] = true;
|
||||||
|
binContainerChanged.notify();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ICElementDelta[] childDeltas = delta.getChangedChildren();
|
||||||
|
for (ICElementDelta childDelta : childDeltas) {
|
||||||
|
if (processDelta(childDelta)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Thread waiter = new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
synchronized (binContainerChanged) {
|
||||||
|
try {
|
||||||
|
binContainerChanged.wait(1000);
|
||||||
|
} catch (InterruptedException exc) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
CoreModel.getDefault().addElementChangedListener(elementChangedListener);
|
||||||
|
|
||||||
|
testProject.close();
|
||||||
|
testProject.open(monitor);
|
||||||
|
|
||||||
|
|
||||||
|
waiter.start();
|
||||||
|
Thread.sleep(50);
|
||||||
|
|
||||||
|
workspace.delete(new IResource[] { resource }, false, monitor);
|
||||||
|
|
||||||
|
// wait for delta notification
|
||||||
|
waiter.join(1000);
|
||||||
|
|
||||||
|
assertEquals(0, testProject.getBinaryContainer().getBinaries().length);
|
||||||
|
assertTrue(binContainerChanged[0]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
testProject.getProject().delete(true, true, monitor);
|
||||||
|
}
|
||||||
|
catch (CoreException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2011 IBM Corporation and others.
|
* Copyright (c) 2002, 2015 IBM Corporation 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
|
||||||
|
@ -601,6 +601,18 @@ final class DeltaProcessor {
|
||||||
case IResourceDelta.REMOVED :
|
case IResourceDelta.REMOVED :
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
elementRemoved(element, delta);
|
elementRemoved(element, delta);
|
||||||
|
} else {
|
||||||
|
// Bug 349564 - The 'Binaries' node does not always disappear when project is cleaned
|
||||||
|
CModel cModel = CModelManager.getDefault().getCModel();
|
||||||
|
ICProject cProject = cModel.findCProject(resource.getProject());
|
||||||
|
if (cProject != null && cProject.isOnOutputEntry(resource)) {
|
||||||
|
IBinaryContainer bin = cProject.getBinaryContainer();
|
||||||
|
if (!bin.isOpen())
|
||||||
|
fCurrentDelta.changed(bin, ICElementDelta.F_CONTENT);
|
||||||
|
IArchiveContainer archive = cProject.getArchiveContainer();
|
||||||
|
if (!archive.isOpen())
|
||||||
|
fCurrentDelta.changed(archive, ICElementDelta.F_CONTENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return element instanceof ICContainer;
|
return element instanceof ICContainer;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2009 QNX Software Systems and others.
|
* Copyright (c) 2000, 2015 QNX Software Systems 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
|
||||||
|
@ -29,7 +29,9 @@ import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
import org.eclipse.cdt.core.model.ElementChangedEvent;
|
||||||
import org.eclipse.cdt.core.model.IArchive;
|
import org.eclipse.cdt.core.model.IArchive;
|
||||||
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
import org.eclipse.cdt.core.model.ICContainer;
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
|
@ -315,7 +317,10 @@ public class CElementContentProvider extends BaseCElementContentProvider impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refresh() {
|
public void refresh() {
|
||||||
if (container.hasChildren()) {
|
if (container instanceof IBinaryContainer || container instanceof IArchiveContainer) {
|
||||||
|
// Always refresh the project to properly show/hide container
|
||||||
|
fViewer.refresh(project);
|
||||||
|
} else if (container.hasChildren()) {
|
||||||
if (fViewer.testFindItem(container) != null) {
|
if (fViewer.testFindItem(container) != null) {
|
||||||
fViewer.refresh(container);
|
fViewer.refresh(container);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue