Page MenuHomePhabricator

Uninitialized images cause crash
Closed, ResolvedPublic

Description

... due to unset geometry. The discussed solution is to initialize a basic geometry in the image constructor.

Event Timeline

Loading an uninitialized image in the Dataset does not cause crash!

It only crashes, when there is another image in the dataset.

Proposed Solution: Add the following lines in the mitk::Image Constructor:

// Initialize the image with minimal values
const unsigned int dim[3] = {1,1,1};
this->Initialize(mitk::MakeScalarPixelType<unsigned char>() , 3, dim, 1);

With this solution there isnt a system crash - there are 'only' VTK errors.
It occure if there is an empty image loaded in the datamanager AND reinit is performed.

VTK errors do not occur, when dimension are higher than 1. Unfortunately, if dimension values in the proposed solution are changed to a higher value, the application crashes.

Intersting: When you do this outside the image class

e.g
QmitkBooleanOperationsView::OnUnionButtonClicked
{
..
// Initialize the image with minimal values
const unsigned int dim[3] = {10,10,10};
this->Initialize(mitk::MakeScalarPixelType<unsigned char>() , 3, dim, 1);
..
}

Works without system crash and without VTK errors.

Proposed solution is commited to bug-branch. Waiting for core flag.

Created a new fix with Marco:

The main issue was, that "timeSlicedGeometry" member of an empty mitk::image had 0 timesteps, but its member bool "valid" was true.

We have overwritten the isValid function for the timeslicedgeometry class, to ensure that "isValid" only returns true, when the timeslicedgeometry has more than 0 timesteps! And Reinit will only reinit the datanode, if its timeslicedgeometry is valid.

Yet, we should consider some more cases:

  • What about the "isValid" status of other baseData objects?
  • Reinit won't do anything if timeslicedgeometry is invalid, but what about "save" such options?

Pushed the new version on the bug branch.

[121fb0]: Merge branch 'bug-11600-InitializeImage'

Merged commits:

2012-05-18 16:08:43 Bastian Graser [7a13f7]
removed tabs


2012-05-16 14:22:48 Bastian Graser [3e2cda]
TimeSlicedGeometry is now having a own isValid function that checks if the number of timesteps is bigger than 0. only then reinit works.


2012-05-16 18:00:19 Bastian Graser [bd1a88]
Reverted "old fix" and applied changes for "new fix"!


2012-05-16 14:22:48 Bastian Graser [8ca333]
Image is getting intialized when constructed