Skip to content

Commit

Permalink
Fixed bug with ASMLauncher, where a previous launch configuration with a
Browse files Browse the repository at this point in the history
matching filename would launch instead of the intended one.
  • Loading branch information
p-a committed Oct 20, 2013
1 parent 84a0bf9 commit aaa09bf
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
2 changes: 1 addition & 1 deletion META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Kick Assembler Plug-in
Bundle-SymbolicName: org.lyllo.kickassplugin; singleton:=true
Bundle-Version: 0.9.26
Bundle-Version: 0.9.27
Bundle-Activator: org.lyllo.kickassplugin.Activator
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Expand Down
20 changes: 10 additions & 10 deletions src/org/lyllo/kickassplugin/launch/ASMLaunchShortcut.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,22 @@ public void launch(ISelection selection, String mode) {

dest = dest.substring(0,dest.lastIndexOf(File.separatorChar)+1) + destName;

String wfile = dest;
int pos = wfile.lastIndexOf(File.separator);

if (pos > 0) {
wfile = wfile.substring(0, pos);
}

try {
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = manager.getLaunchConfigurationType(Constants.LAUNCH_CONFIGURATION_TYPE_ID);
ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type);

for (ILaunchConfiguration config : configs) {
if (config.getAttribute(Constants.LAUNCH_FILE, "").equalsIgnoreCase(destName)) {
if (config.getAttribute(Constants.LAUNCH_FILE, "").equalsIgnoreCase(destName) &&
config.getAttribute(Constants.LAUNCH_WORKING_DIRECTORY,"").equalsIgnoreCase(wfile)
) {
DebugUITools.launch(config, mode);
return;
}
Expand All @@ -158,15 +167,6 @@ public void launch(ISelection selection, String mode) {
null,
manager.generateUniqueLaunchConfigurationNameFrom(Messages.EXECUTABLE_NAME));
copy.setAttribute(Constants.LAUNCH_FILE, destName);


String wfile = dest;
int pos = wfile.lastIndexOf(File.separator);

if (pos > 0) {
wfile = wfile.substring(0, pos);
}

copy.setAttribute(Constants.LAUNCH_WORKING_DIRECTORY, wfile);
copy.setAttribute(Constants.LAUNCH_ARGUMENTS, "");
ILaunchConfiguration config = copy.doSave();
Expand Down
37 changes: 22 additions & 15 deletions src/org/lyllo/kickassplugin/launch/ASMLauncher.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
Kick Assembler plugin - An Eclipse plugin for convenient Kick Assembling
Copyright (c) 2012 - P-a Backstrom <pa.backstrom@gmail.com>
Based on ASMPlugin - http://sourceforge.net/projects/asmplugin/
Copyright (c) 2006 - Andy Reek, D. Mitte
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
Expand All @@ -18,7 +18,7 @@ of the License, or (at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
*/
package org.lyllo.kickassplugin.launch;

import java.io.BufferedWriter;
Expand Down Expand Up @@ -67,42 +67,48 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
}

String launchWorkingDirectory = configuration.getAttribute(Constants.LAUNCH_WORKING_DIRECTORY, "");
if (launchWorkingDirectory == null || launchWorkingDirectory.trim().length() == 0){
if (launchWorkingDirectory == null || (launchWorkingDirectory = launchWorkingDirectory.trim()).length() == 0){
return;
}

String launchFile = configuration.getAttribute(Constants.LAUNCH_FILE, "");

if ((launchFile == null) || (launchFile.trim().length() < 1)) {
if ((launchFile == null) || ( (launchFile = launchFile.trim()).length() < 1)) {
return;
}

String filename;
StringBuilder filenameBuilder = new StringBuilder();

filenameBuilder.append(launchWorkingDirectory);
if (launchFile.lastIndexOf(File.separatorChar) > -1){
filename = launchWorkingDirectory + launchFile.substring(launchFile.lastIndexOf(File.separatorChar));
filenameBuilder.append(launchFile.substring(launchFile.lastIndexOf(File.separatorChar)));
} else if (launchFile.lastIndexOf('/') > -1) {
filename = launchWorkingDirectory + launchFile.substring(launchFile.lastIndexOf('/'));
filenameBuilder.append(launchFile.substring(launchFile.lastIndexOf('/')));
} else {
filename = launchWorkingDirectory + File.separator + launchFile;
filenameBuilder.append(File.separator).append(launchFile);
}

String sep = File.separator;
if (sep.charAt(0) != '/') {
sep = "\\" + sep; //This is weird
}

filename = filename.replaceAll("/", sep);

while (filename.length() > 0 && filename.charAt(0) == '\\'){
filename = filename.substring(1);
String filename = filenameBuilder.toString().replaceAll("/", sep);

{
int i = 0;
while (filename.length() > i && filename.charAt(i) == '\\'){
i++;
}
filename = filename.substring(i);
}

List<String> cmds = new ArrayList<String>();
cmds.add(debugger.trim());

for (String param: params.trim().split("\\n")){
if (!"".equals(param.trim())){
cmds.add(param.trim());
if (!"".equals((param=param.trim()))){
cmds.add(param);
}
}

Expand Down Expand Up @@ -143,6 +149,7 @@ public void launch(ILaunchConfiguration configuration, String mode, ILaunch laun
} finally {
if (writer != null){
try {
writer.flush();
writer.close();
} catch (IOException e) {
}
Expand Down

0 comments on commit aaa09bf

Please sign in to comment.