Page MenuHomePhabricator

SetDataStorage function should not remove and re-add listeners if data storage does not change
Closed, ResolvedPublic

Description

The SetDataStorage function in mitk::BaseRenderer and mitk::BindDispatcherInteractor should check if the new data storage is the same as the actual one and if it is, no action should be performed.

Rationale:

I had a crash because of the current behaviour in our MITK based application when I opened a file. When a new file is added to the data storage, a copy is made of the list of current DataNodeAdd event listeners, and they are notified in a loop. The data manager opens a new editor. In my app there is an extra renderer in a view that is updated from the main editor. So that it is automatically updated, it is added to the same rendering manager as what the main editor has. The mitk::RenderingManager::AddRenderWindow(...) call, however, resets the data storage of the renderer, and even if the data storage is the same (like in my case), this call removes the old listener and adds a new one. The old listener is then destructed.

However, we are still iterating through the data node add event listeners (after the file open), and the copy list of listeners has now an invalid object, and when we reach it, the application crashes.

I hope it makes sense. :)

I will send a PR soon.

Event Timeline

[c5ddcd]: Merge branch 'bug-19390-Integration'

Merged commits:

2016-02-24 13:52:08 Stefan Kislinskiy [aa5506]
Replace NULL with nullptr


2016-02-24 13:48:05 Stefan Kislinskiy [5efc6d]
Merge remote-tracking branch 'NifTK/bug-19390-SetDataStorage-arg-check' into bug-19390-Integration


2015-10-22 16:22:02 Miklos Espak [570f2c]
SetDataStorage functions do not remove and re-add listeners

Signed-off-by: Miklos Espak <m.espak@ucl.ac.uk>