diff --git a/apps/systray/java/src/net/i2p/apps/systray/ShellCommand.java b/apps/systray/java/src/net/i2p/apps/systray/ShellCommand.java index d8f50d3f4..144d5491b 100644 --- a/apps/systray/java/src/net/i2p/apps/systray/ShellCommand.java +++ b/apps/systray/java/src/net/i2p/apps/systray/ShellCommand.java @@ -17,7 +17,8 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; /** - * Passes a command to the OS shell for execution and manages the output. + * Passes a command to the OS shell for execution and manages the input and + * output. *
* This class must be kept gcj
-compatible.
*
@@ -35,6 +36,7 @@ public class ShellCommand {
private CommandThread _commandThread;
private InputStream _errorStream;
private InputStream _inputStream;
+ private boolean _isTimerRunning;
private OutputStream _outputStream;
private Process _process;
@@ -45,11 +47,11 @@ public class ShellCommand {
*/
private class CommandThread extends Thread {
- Object caller;
+ Thread caller;
boolean consumeOutput;
String shellCommand;
- CommandThread(Object caller, String shellCommand, boolean consumeOutput) {
+ CommandThread(Thread caller, String shellCommand, boolean consumeOutput) {
super("CommandThread");
this.caller = caller;
this.shellCommand = shellCommand;
@@ -58,8 +60,10 @@ public class ShellCommand {
public void run() {
_commandSuccessful = execute(shellCommand, consumeOutput, WAIT_FOR_EXIT_STATUS);
- synchronized(caller) {
- caller.notify(); // In case the caller is still in the wait() state.
+ if (_isTimerRunning) {
+ synchronized(caller) {
+ caller.interrupt(); // In case the caller is still in the wait() state.
+ }
}
}
}
@@ -236,13 +240,16 @@ public class ShellCommand {
try {
if (seconds > 0) {
+ _isTimerRunning = true;
wait(seconds * 1000);
+ _isTimerRunning = false;
return true;
}
} catch (InterruptedException e) {
// Wake up, time to die.
}
+ _isTimerRunning = false;
if (_commandSuccessful)
return true;
@@ -302,13 +309,16 @@ public class ShellCommand {
try {
if (seconds > 0) {
+ _isTimerRunning = true;
wait(seconds * 1000);
+ _isTimerRunning = false;
return true;
}
} catch (InterruptedException e) {
// Wake up, time to die.
}
+ _isTimerRunning = false;
if (_commandSuccessful)
return true;
diff --git a/apps/systray/java/src/net/i2p/apps/systray/SysTray.java b/apps/systray/java/src/net/i2p/apps/systray/SysTray.java
index a35f40ca8..6c7ba3e9a 100644
--- a/apps/systray/java/src/net/i2p/apps/systray/SysTray.java
+++ b/apps/systray/java/src/net/i2p/apps/systray/SysTray.java
@@ -51,6 +51,9 @@ public class SysTray implements SysTrayMenuListener {
public void iconLeftClicked(SysTrayMenuEvent e) {}
public void iconLeftDoubleClicked(SysTrayMenuEvent e) {
+
+ String browser = null;
+
if (_browserString == null || _browserString.equals("default")) {
try {
@@ -70,7 +73,10 @@ public class SysTray implements SysTrayMenuListener {
// Fall through.
}
}
- setBrowser(promptForBrowser("Please select another browser"));
+
+ if ((browser = promptForBrowser("Please select another browser")) != null)
+ setBrowser(browser);
+
}
public void menuItemSelected(SysTrayMenuEvent e) {
@@ -98,9 +104,15 @@ public class SysTray implements SysTrayMenuListener {
}
private String promptForBrowser(String windowTitle) {
+
+ String browser = null;
+
_frame = new Frame();
_browserChooser = new BrowserChooser(_frame, windowTitle);
- return _browserChooser.getDirectory() + _browserChooser.getFile();
+ browser = _browserChooser.getDirectory() + _browserChooser.getFile();
+ _browserChooser = null;
+ _frame = null;
+ return browser;
}
private void setBrowser(String browser) {