Fixed crash for single time step segmentations
kausch Authored on Apr 26 2019, 11:40 AM kausch Pushed on Apr 26 2019, 11:40 AM
- rMITK55cb5498ee4d: Added Try-Catch For Multiple Timepoints Segmentation
The fix is not good and has several problems. See comment above. If it is not clear how to handle it properly, just drop by an I can explaine.
You cannot just create a container on the fly on the heap and pass it back as a reference.
Don't do that.
The correct way to handle this with the current API is to either
If the time step does not exist it is job of the caller to specify the fallback strategy. It is not part of the container to specify or enforce anything in this direction.
One correction. It will not cause crash (that would be the case with smartpointers as raw pointers. Currently it will generate memory leaks.
I second that. I also ran into this problem when using the classes for my own plugin. For testing I only added a mask at one time step -> crash.
Checking in any way if 'GetStatisticsForTimeStep' is successfully without directly accessing 'm_Histogram' seems to be the correct way to go.
There seems to be another exception thrown when willing the table view. The statistics table is not filled. The idea is now not to change the GetStatisticsForTimeStep functionality but handle the exception in the level above (like we started before with the try-catch)
We reverted the changes according to your concerns. Instead of creating a new ImageStatisticsObject in the GetStatisticsForTimeStep method, we now check whether the time step exists before calling the method. That fixed the problem. Statistics are now only shown for the time steps that have a segmentation associated with.