From 68c2b37b32f11f8a8e0b2e8798850d444d32a86a Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Mon, 2 Jun 2008 16:40:18 +0000 Subject: [PATCH] [234296] - [source lookup] Source lookup open "" editor after after launching two multiple duplicate debug sessions. --- .../sourcelookup/DsfSourceLookupDirector.java | 3 +- .../launching/GdbLaunchDelegate.java | 36 +++++++------------ 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/sourcelookup/DsfSourceLookupDirector.java b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/sourcelookup/DsfSourceLookupDirector.java index a4030848efd..d4e1fd48360 100644 --- a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/sourcelookup/DsfSourceLookupDirector.java +++ b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/sourcelookup/DsfSourceLookupDirector.java @@ -30,7 +30,8 @@ public class DsfSourceLookupDirector extends CSourceLookupDirector { /* (non-Javadoc) * @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants() */ - public void initializeParticipants() { + @Override + public void initializeParticipants() { addParticipants( new ISourceLookupParticipant[]{ new DsfSourceLookupParticipant(fSession) } ); } diff --git a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java index 7e183809d96..f4a202f7ffb 100644 --- a/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java +++ b/plugins/org.eclipse.dd.gdb/src/org/eclipse/dd/gdb/internal/provisional/launching/GdbLaunchDelegate.java @@ -38,19 +38,18 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.dd.dsf.concurrent.ThreadSafe; +import org.eclipse.dd.dsf.debug.sourcelookup.DsfSourceLookupDirector; +import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.gdb.internal.GdbPlugin; import org.eclipse.dd.gdb.internal.provisional.IGDBLaunchConfigurationConstants; import org.eclipse.dd.gdb.internal.provisional.service.command.GDBControl.SessionType; import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2; -import org.eclipse.debug.core.model.IPersistableSourceLocator; import org.eclipse.debug.core.model.ISourceLocator; import org.eclipse.debug.core.model.LaunchConfigurationDelegate; -import org.eclipse.debug.core.sourcelookup.IPersistableSourceLocator2; /** * The shared launch configuration delegate for the DSF/GDB debugger. @@ -197,30 +196,21 @@ public class GdbLaunchDelegate extends LaunchConfigurationDelegate // because once the launch is created and added to launch manager, // the adapters will be created for the whole session, including // the source lookup adapter. - ISourceLocator locator = getSourceLocator(configuration); - return new GdbLaunch(configuration, mode, locator); + GdbLaunch launch = new GdbLaunch(configuration, mode, null); + launch.setSourceLocator(getSourceLocator(configuration, launch.getSession())); + return launch; } - private ISourceLocator getSourceLocator(ILaunchConfiguration configuration) throws CoreException { - String type = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null); - if (type == null) { - type = configuration.getType().getSourceLocatorId(); + private ISourceLocator getSourceLocator(ILaunchConfiguration configuration, DsfSession session) throws CoreException { + DsfSourceLookupDirector locator = new DsfSourceLookupDirector(session); + String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); + if (memento == null) { + locator.initializeDefaults(configuration); + } else { + locator.initializeFromMemento(memento, configuration); } - if (type != null) { - IPersistableSourceLocator locator = DebugPlugin.getDefault().getLaunchManager().newSourceLocator(type); - String memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); - if (memento == null) { - locator.initializeDefaults(configuration); - } else { - if(locator instanceof IPersistableSourceLocator2) - ((IPersistableSourceLocator2)locator).initializeFromMemento(memento, configuration); - else - locator.initializeFromMemento(memento); - } - return locator; - } - return null; + return locator; } /**