Re: [visad] Changes to visad.util.TextEditor

Hi Jeff,

Your changes make sense. Alternately, you could make TextEditor implement
Runnable, have fileChooser get instantiated in the run() method, and invoke
it from the constructor with the SwingUtilities.invokeLater method -- this
would constrain the creation to a single thread, which if I understand your
message correctly would prevent the deadlock issue.

-Curtis

On Sat, Jan 24, 2009 at 9:20 AM, Jeff McWhirter <jeffmc@xxxxxxxxxxxxxxxx>wrote:

>
> Hi,
> If you never access or subclass visad.util.TextEditor then please ignore
> this message.
>
> We have come across a deadlock problem in the IDV running on windows
> under jdk1.6.
> This problem is caused by creating JFileChooser objects in multiple
> threads.
>
> I'd like to change the fileChooser member of visad.util.TextEditor from
> protected to private so that this member
> does not get created at object instantiation time but rather gets
> created when needed. I have also
> modified visad.python.JPythonEditor because it would directly access
> that member.
>
> Is this going to break anyone's code?
>
> Thanks,
> Jeff
>
>
> The proposed changes:
> In TextEditor add:
>
>  /** Create and initialize the the file chooser */
>  protected JFileChooser doMakeFileChooser() {
>       JFileChooser tmpChooser = new
> JFileChooser(System.getProperty("user.dir"));
>       tmpChooser.addChoosableFileFilter(
>         new ExtensionFileFilter("txt", "Text files"));
>       return tmpChooser;
>  }
>
>
>  /** Create if needed and return the file chooser */
>  protected JFileChooser getFileChooser() {
>    if(fileChooser == null) {
>       fileChooser = doMakeFileChooser();
>    }
>    return fileChooser;
>  }
>
>
> Any access to fileChooser in these classes is changed to getFileChooser()
>
> In visad.python.JPythonEditor overwrite the doMakeFileChooser to add the
> file filter:
>  /** Create and initialize the the file chooser */
>  protected JFileChooser doMakeFileChooser() {
>      JFileChooser tmpFileChooser = super.doMakeFileChooser();
>      // add JPython files to file chooser dialog box
>      tmpFileChooser.addChoosableFileFilter(
>          new ExtensionFileFilter("py", "JPython source code"));
>      return tmpFileChooser;
>  }
>
>
>
>
> _______________________________________________
> visad mailing list
> visad@xxxxxxxxxxxxxxxx
> For list information, to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: