Ticket #482 (closed defect: duplicate)

Opened 8 years ago

Last modified 8 years ago

Delete Dataset on final Display Closed

Reported by: gharris Owned by: curtis
Priority: major Milestone: biweekly-2011: Apr-25 to May-06
Component: Data Model Version:
Severity: major Keywords:
Cc: Blocked By:


Call Dataset.delete() when associated displays are all closed (reference counting?)

Change History

comment:1 Changed 8 years ago by bdezonia

  • Owner changed from bdezonia to curtis
  • Status changed from new to assigned

I started to put code in SwingDisplayWindow and then determined that Dataset::decrementReferences() was getting already getting called in DatasetView::dispose(). Is this bug already fixed?

comment:2 Changed 8 years ago by bdezonia

It looks like Dataset.delete() just fires an event. Need to determine who "owns" Datasets and is responsible for setting places where its referenced to null. Make them listen for the event and null out references in relvant placces

DatasetView increments and decrements ref counts. Does the legacy layer need to also? Is there a repository of all Datasets right now (something more comprehensive than just within the legacy layer)? Who is keeping these Dataset references around right now? Will investigate further but feel free to fill me in further.

comment:3 Changed 8 years ago by bdezonia

Started writing a DatasetManager class in ij-data. It will track created/deleted events. ObjectManager is already doing this to some degree. But its not Dataset specific.

Not sure at the moment who is keeping the references around right now (legacy?). If legacy is then on dataset deletion event DatasetMgr can tell LegacyManager to remove the Dataset from its internal structures. However that would cause ij-data to have a dependency on ij-legacy to get access to its manager. Probably not desirable.

Curtis, I've left this assigned to you in order to get feedback.

comment:4 Changed 8 years ago by bdezonia

Realized that if legacy needs to know about deletions it can just subscribe to the events themselves. We may not need a DatasetManager.

comment:5 Changed 8 years ago by curtis

  • Status changed from assigned to closed
  • Resolution set to duplicate

Duplicate of #413, already fixed.

When a view goes away, Dataset.decrementReferences() is called, which calls delete() when it hits zero (i.e., no active display views for that Dataset remain). The delete() call fires a DatasetDeletedEvent that is picked up by ObjectManager, which removes the Dataset from the hoard. Hence, plugins that require Dataset inputs (e.g., Image Calculator) no longer list that Dataset as a viable option.

The main thing left to check is that LegacyImageMap cleans up properly when a legacy-generated Dataset goes away. For example, Open Samples > Clown produces an image window, which when closed, should not leave anything lingering in the LegacyImageMap's WeakHashMap. In theory, no ImagePlus or Dataset objects should remain in the hash, but it may be worth some testing to be sure.

Note: See TracTickets for help on using tickets.