Skip to content

Commit

Permalink
fixes for run from gui
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Feb 10, 2024
1 parent 1561282 commit 2fce962
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ public static void run(Class<? extends MATSimApplication> clazz, String... args)
// Pass stored args to the instance as well
if (System.getenv().containsKey("MATSIM_GUI_ARGS")) {
String[] guiArgs = System.getenv("MATSIM_GUI_ARGS").split(ARGS_DELIMITER);
args = ApplicationUtils.mergeArgs(args, guiArgs);
if (guiArgs.length > 0)
args = ApplicationUtils.mergeArgs(args, guiArgs);
}
}

Expand Down Expand Up @@ -376,9 +377,12 @@ public static void runWithDefaults(Class<? extends MATSimApplication> clazz, Str

if (ApplicationUtils.isRunFromDesktop()) {

String value = String.join(ARGS_DELIMITER, defaultArgs);
System.getenv().put("MATSIM_GUI_ARGS", value);
if (defaultArgs.length > 0) {
String value = String.join(ARGS_DELIMITER, defaultArgs);
System.setProperty("MATSIM_GUI_ARGS", value);
}

// args should be empty when run from desktop and is not used
run(clazz, "gui");

} else {
Expand Down
4 changes: 2 additions & 2 deletions matsim/src/main/java/org/matsim/run/gui/ExeRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public void run() {

// Copy the MATSIM_GUI_ARGS environment variable to the process environment
// these arguments may be used internally by the matsim scenario
if (System.getenv().containsKey("MATSIM_GUI_ARGS")) {
processBuilder.environment().put("MATSIM_GUI_ARGS", System.getenv("MATSIM_GUI_ARGS"));
if (System.getProperty("MATSIM_GUI_ARGS") != null) {
processBuilder.environment().put("MATSIM_GUI_ARGS", System.getProperty("MATSIM_GUI_ARGS"));
}

if (workingDirectory != null) {
Expand Down

0 comments on commit 2fce962

Please sign in to comment.