Common runtime errors

From OTBWiki
Revision as of 18:44, 4 January 2013 by SebastienDinot (Talk | contribs) (Reverted edits by AmosHolt (Talk) to last revision by WikiSysop)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page is intended to describe common runtime errors encountered by developers as well as their possible causes. You may also want to have a look at compilation errors.

Streaming and variables scopes

If we consider the following case:

ViewerType::Pointer viewer = ViewerType::New();
if(use_overlay)
  {
     ReaderType::Pointer reader = ReaderType::New();
     reader->SetFileName(filename);
     viewer->SetInputOverlay(reader->GetOutput();
  }
viewer->Build();
viewer->Update();

The scope of the reader variable is limited to the brackets. Therefore, by the time viewer->Build() and viewer->Update() are called, the reader has already been deleted. Note that the reader output image still exists, thanks to reference counting and to viewer->SetInputOverlay(reader->GetOutput();. It is only unplugged from the reader. This will cause any attempt to update a new requested region of the image to fail, because it has no more source.

If you want to use an pipeline with streaming, you must ensure that none of your filters (including the reader) is destroyed before your are over with what you were up to stream.