fix race condition likely causing null ptr exception when registering a listener.

Fixes #218
This commit is contained in:
adam-m 2013-06-12 22:38:51 -04:00
parent da6943426b
commit cdfe03290f

View File

@ -31,9 +31,9 @@ import javax.swing.event.DocumentListener;
* ImageTypePanel for adding an image file such as .img, .E0x, .00x, etc. * ImageTypePanel for adding an image file such as .img, .E0x, .00x, etc.
*/ */
public class ImageFilePanel extends ContentTypePanel implements DocumentListener { public class ImageFilePanel extends ContentTypePanel implements DocumentListener {
private static ImageFilePanel instance; private static volatile ImageFilePanel instance = null;
private PropertyChangeSupport pcs = new PropertyChangeSupport(this); private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
private JFileChooser fc = new JFileChooser(); private final JFileChooser fc = new JFileChooser();
/** /**
* Creates new form ImageFilePanel * Creates new form ImageFilePanel
@ -53,7 +53,7 @@ public class ImageFilePanel extends ContentTypePanel implements DocumentListener
/** /**
* Returns the default instance of a ImageFilePanel. * Returns the default instance of a ImageFilePanel.
*/ */
public static ImageFilePanel getDefault() { public static synchronized ImageFilePanel getDefault() {
if (instance == null) { if (instance == null) {
instance = new ImageFilePanel(); instance = new ImageFilePanel();
} }