Changeset 921aef7f


Ignore:
Timestamp:
Aug 21, 2004 11:01:12 AM (17 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
c9d4745
Parents:
3c772f1
git-author:
hypercubus <hypercubus> (08/21/04 11:01:12)
git-committer:
zzz <zzz@…> (08/21/04 11:01:12)
Message:

fixed a silly thread blocking problem

Location:
apps/systray/java/src/net/i2p/apps/systray
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/systray/java/src/net/i2p/apps/systray/ShellCommand.java

    r3c772f1 r921aef7f  
    1818
    1919/**
    20  * Passes a command to the OS shell for execution and manages the output.
     20 * Passes a command to the OS shell for execution and manages the input and
     21 * output.
    2122 * <p>
    2223 * This class must be kept <code>gcj</code>-compatible.
     
    3637    private InputStream   _errorStream;
    3738    private InputStream   _inputStream;
     39    private boolean       _isTimerRunning;
    3840    private OutputStream  _outputStream;
    3941    private Process       _process;
     
    4648    private class CommandThread extends Thread {
    4749
    48         Object  caller;
     50        Thread  caller;
    4951        boolean consumeOutput;
    5052        String  shellCommand;
    5153
    52         CommandThread(Object caller, String shellCommand, boolean consumeOutput) {
     54        CommandThread(Thread caller, String shellCommand, boolean consumeOutput) {
    5355            super("CommandThread");
    5456            this.caller = caller;
     
    5961        public void run() {
    6062            _commandSuccessful = execute(shellCommand, consumeOutput, WAIT_FOR_EXIT_STATUS);
    61             synchronized(caller) {
    62                 caller.notify();  // In case the caller is still in the wait() state.
     63            if (_isTimerRunning) {
     64                synchronized(caller) {
     65                    caller.interrupt();  // In case the caller is still in the wait() state.
     66                }
    6367            }
    6468        }
     
    237241
    238242            if (seconds > 0) {
     243                _isTimerRunning = true;
    239244                wait(seconds * 1000);
     245                _isTimerRunning = false;
    240246                return true;
    241247            }
     
    244250            // Wake up, time to die.
    245251        }
     252        _isTimerRunning = false;
    246253
    247254        if (_commandSuccessful)
     
    303310
    304311            if (seconds > 0) {
     312                _isTimerRunning = true;
    305313                wait(seconds * 1000);
     314                _isTimerRunning = false;
    306315                return true;
    307316            }
     
    310319            // Wake up, time to die.
    311320        }
     321        _isTimerRunning = false;
    312322
    313323        if (_commandSuccessful)
  • apps/systray/java/src/net/i2p/apps/systray/SysTray.java

    r3c772f1 r921aef7f  
    5252
    5353    public void iconLeftDoubleClicked(SysTrayMenuEvent e) {
     54
     55        String browser = null;
     56
    5457        if (_browserString == null || _browserString.equals("default")) {
    5558            try {
     
    7174            }
    7275        }
    73         setBrowser(promptForBrowser("Please select another browser"));
     76
     77        if ((browser = promptForBrowser("Please select another browser")) != null)
     78            setBrowser(browser);
     79
    7480    }
    7581
     
    99105
    100106    private String promptForBrowser(String windowTitle) {
     107
     108        String browser = null;
     109
    101110        _frame = new Frame();
    102111        _browserChooser = new BrowserChooser(_frame, windowTitle);
    103         return _browserChooser.getDirectory() + _browserChooser.getFile();
     112        browser = _browserChooser.getDirectory() + _browserChooser.getFile();
     113        _browserChooser = null;
     114        _frame = null;
     115        return browser;
    104116    }
    105117
Note: See TracChangeset for help on using the changeset viewer.