Opened 9 years ago

Last modified 9 years ago

#680 assigned enhancement

Make deleting Model or Drawing notify parent.

Reported by: tic20@… Owned by: Tom Goddard
Priority: major Milestone:
Component: Core Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Want to be able to use

m.delete()

instead of

session.models.remove([m])

and for Drawing

d.delete()

instead of

parent.remove_drawings([d])

Begin forwarded message:

From: Tristan Croll
Subject: Re: Pseudobonds question (and crash)
Date: May 18, 2017 at 11:23:18 AM PDT
To: Tom Goddard

...

Another issue I ran into today: if I've created a Drawing (call it d) and added it to a Model, then running:

d.delete()

does Very Bad Things(TM) (the drawing loop crashes). The immediate cause is fairly straightforward (the Drawing object tries to measure the length of a variable that's been set to None). If I run delete() on a Model object, the entry remains in the Model panel.

I'm not sure if delete() was meant to be used this way, but it's what seemed the intuitive thing to me. Perhaps it would be better if delete() was a a synonym for chimerax.core.commands.close(session, self) and the current delete() turned into a hidden method?

Tristan Croll
Research Fellow
Cambridge Institute for Medical Research
University of Cambridge CB2 0XY

Change History (1)

comment:1 by Tom Goddard, 9 years ago

Begin forwarded message:

From: Tom Goddard
Subject: Deleting ChimeraX Drawings
Date: May 19, 2017 at 3:57:52 PM PDT
To: Tristan Croll

Hi Tristan,

To delete an open model use

session.models.remove([m])

I agree it would be nice if a Model new that belonged to the Models manager (session.models). But it doesn’t. So if you instead use

m.delete()

then the Model is deleted and the Models manager still has it in its list and so it still gets drawn generating an error. Same situation for Drawing, a Drawing does not know it is owned by its parent so

d.delete()

deletes the drawing but the parent still lists it as a child, and so it tries to draw it and you get an error. The proper way to delete a drawing is

parent.remove_drawings([d])

The above is not so strange. If an object is owned by another object you generally tell the owner to delete the object so it does not keep a dangling pointer. But having objects know about their owners is also common and convenient. I’ll make a ticket to look into that for Drawing/Model in the future.

Tom

Note: See TracTickets for help on using tickets.