# Buggy code
def set_display_well(self, well):
    """Set the display well and redraw the figure"""
    with self.image_dict_lock:
        self.image_dict = {}
        self.image_dict_generation += 1

    def fn():
        cellprofiler.utilities.jutil.attach()
        with self.image_dict_lock:
            generation = self.image_dict_generation

        for k, v in well.iteritems():
            sd = {}
            with self.image_dict_lock:
                if self.image_dict_generation > generation:
                    return
                self.image_dict[k] = sd
            for c, fd in enumerate(v):
                if PlateData.D_CHANNEL in fd:
                    channel = fd[PlateData.D_CHANNEL]
                else:
                    channel = str(c + 1)
                img = load_using_bioformats_url(fd[PlateData.D_FILENAME])
                with self.image_dict_lock:
                    if self.image_dict_generation > generation:
                        return
                    sd[channel] = img
        wx.CallAfter(self.update_figure)
        cellprofiler.utilities.jutil.detach()

    t = threading.Thread(target=fn)
    t.setDaemon(True)
    t.start()


# Traceback (AttributeError)
Traceback (most recent call last):
File "/Applications/CellProfiler_2.1_r20131015204003.app/Contents/Resources/lib/python2.7/cellprofiler/gui/cpframe.py", line 781, in on_data_tool
File "/Applications/CellProfiler_2.1_r20131015204003.app/Contents/Resources/lib/python2.7/cellprofiler/gui/cpframe.py", line 1327, in __on_data_tool
File "/Applications/CellProfiler_2.1_r20131015204003.app/Contents/Resources/lib/python2.7/cellprofiler/gui/datatoolframe.py", line 79, in __init__
File "/Applications/CellProfiler_2.1_r20131015204003.app/Contents/Resources/lib/python2.7/cellprofiler/gui/moduleview.py", line 392, in set_selection
AttributeError: 'NoneType' object has no attribute 'Show'

# Fixed code
def set_display_well(self, well):
    """Set the display well and redraw the figure"""
    with self.image_dict_lock:
        self.image_dict = {}
        self.image_dict_generation += 1

    def fn():
        cellprofiler.utilities.jutil.attach()
        with self.image_dict_lock:
            generation = self.image_dict_generation

        for k, v in well.iteritems():
            sd = {}
            with self.image_dict_lock:
                if self.image_dict_generation > generation:
                    return
                self.image_dict[k] = sd
            for c, fd in enumerate(v):
                if PlateData.D_CHANNEL in fd:
                    channel = fd[PlateData.D_CHANNEL]
                else:
                    channel = str(c + 1)
                try:
                    img = load_using_bioformats_url(fd[PlateData.D_FILENAME])
                    with self.image_dict_lock:
                        if self.image_dict_generation > generation:
                            return
                        sd[channel] = img
                except:
                    traceback.print_exc()
                    pass
        wx.CallAfter(self.update_figure)
        cellprofiler.utilities.jutil.detach()

    t = threading.Thread(target=fn)
    t.setDaemon(True)
    t.start()