1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

ISourceFinder needs a dispose method.

This commit is contained in:
John Cortell 2010-01-14 13:59:52 +00:00
parent 7ce6589439
commit 289a7c8dfa
4 changed files with 85 additions and 55 deletions

View file

@ -309,7 +309,7 @@ public class Binary extends Openable implements IBinary {
String[] sourceFiles = symbolreader.getSourceFiles(); String[] sourceFiles = symbolreader.getSourceFiles();
if (sourceFiles != null && sourceFiles.length > 0) { if (sourceFiles != null && sourceFiles.length > 0) {
ISourceFinder srcFinder = (ISourceFinder) getAdapter(ISourceFinder.class); ISourceFinder srcFinder = (ISourceFinder) getAdapter(ISourceFinder.class);
try {
for (String filename : sourceFiles) { for (String filename : sourceFiles) {
// Find the file locally // Find the file locally
@ -371,6 +371,13 @@ public class Binary extends Openable implements IBinary {
} }
return true; return true;
} }
finally {
if (srcFinder != null) {
srcFinder.dispose();
}
}
}
return false; return false;
} }

View file

@ -50,6 +50,9 @@ import org.eclipse.core.runtime.IPath;
* launch configuration. In all cases, the global locator is consulted if no other locator has converted the * launch configuration. In all cases, the global locator is consulted if no other locator has converted the
* file. * file.
* *
* <p>A new instance is created every time a Binary object is queried for this interface. Clients must call
* {@link #dispose()} when it is done with the object.
*
* @since 5.2 * @since 5.2
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
@ -103,5 +106,10 @@ public interface ISourceFinder {
*/ */
public String toLocalPath(IAdaptable launch, String compilationPath); public String toLocalPath(IAdaptable launch, String compilationPath);
/**
* Clients must call this to ensure that the object properly cleans up. E.g., a source finder may register
* itself as a listener for changes that would effect how it searches for files. Calling this method will
* allow it to unregister itself.
*/
public void dispose();
} }

View file

@ -34,4 +34,10 @@ public class StandardSourceFileRemapping implements ISourceFileRemapping {
return filePath; return filePath;
} }
/* (non-Javadoc)
* @see java.lang.Object#finalize()
*/
public void finalize(){
srcFinder.dispose();
}
} }

View file

@ -381,4 +381,13 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene
public void launchesChanged(ILaunch[] launches) { public void launchesChanged(ILaunch[] launches) {
// don't care. I don't think setting a new locator in a launch would result in us getting notified // don't care. I don't think setting a new locator in a launch would result in us getting notified
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.ISourceFinder#dispose()
*/
public void dispose() {
ILaunchManager lmgr = DebugPlugin.getDefault().getLaunchManager();
lmgr.removeLaunchConfigurationListener(this);
lmgr.removeLaunchListener(this);
}
} }