Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#835 closed defect (invalid)

Order of events on ToolInstance deletion

Reported by: Tristan Croll Owned by: Conrad Huang
Priority: major Milestone:
Component: Tool Shed Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

From the ChimeraX programming guide under ToolInstance:

delete()

Delete this tool instance.

This method should be overridden to clean up tool data structures. This base method should be called as the last step of tool deletion.

In ISOLDE I have a function _on_close() which needs to be run when ISOLDE is closed to clean up a range of trigger handlers etc. In tool.py I have:

class ISOLDE_ToolUI(ToolInstance):
    SESSION_ENDURING = False
    def __init__(self, session, tool_name):
        # Lots of other setup stuff
        from . import isolde
        self.isolde = isolde.Isolde(self)

    def delete(self):
        self.isolde._on_close()
        super().delete()

Everything else works, but on closing the ISOLDE window I get:

  File "/home/tic20/apps/chimerax/lib/python3.6/site-packages/chimerax/core/ui/gui.py", line 1048, in <lambda>
    dw.closeEvent = lambda e, tw=tool_window, mw=mw: mw.close_request(tw, e)
  File "/home/tic20/apps/chimerax/lib/python3.6/site-packages/chimerax/core/ui/gui.py", line 428, in close_request
    tool_instance.delete()
  File "/home/tic20/.local/share/ChimeraX/0.1/site-packages/chimerax/isolde/tool.py", line 172, in delete
    self.isolde._on_close()
AttributeError: 'ISOLDE_ToolUI' object has no attribute 'isolde'

... which is really rather odd.

Change History (3)

comment:1 by Tristan Croll, 8 years ago

Resolution: invalid
Status: assignedclosed

Actually, never mind. Just double-checked and I only get the traceback if I close ChimeraX with ISOLDE still running. If I just close the ISOLDE window it behaves fine.

comment:2 by Conrad Huang, 8 years ago

You shouldn't get a traceback either way.

The instance might be getting deleted twice. Without looking at the code, I don't know why it lost the "isolde" attribute. Does the error occur when you restore from a session or from a fresh start? Can you do a

traceback.print_stack(file=sys.__stderr__)

in your "delete" method so we can figure out where things are going south?

in reply to:  3 ; comment:3 by tic20@…, 8 years ago

... and now I can't replicate it at all. Not sure what's changed, but I 
was seeing it quite regularly for some time. Will put a try/except 
around it and send you the full stack if/when I see it again.

On 2017-09-14 18:35, ChimeraX wrote:
Note: See TracTickets for help on using tickets.