Difference between revisions of "Common runtime errors"

From OTBWiki
Jump to: navigation, search
m (Reverted edits by Ulofyvy (Talk); changed back to last version by Christop)
Line 2: Line 2:
 
You may also want to have a look at [[Common_compilation_errors|compilation errors]].
 
You may also want to have a look at [[Common_compilation_errors|compilation errors]].
  
>=== Streaming and variables scopes ===
+
=== Streaming and variables scopes ===
 
If we consider the following case:
 
If we consider the following case:
 
  ViewerType::Pointer viewer = ViewerType::New();
 
  ViewerType::Pointer viewer = ViewerType::New();
Line 8: Line 8:
 
   {
 
   {
 
       ReaderType::Pointer reader = ReaderType::New();
 
       ReaderType::Pointer reader = ReaderType::New();
       reader->SetFileName(filename);
+
       reader->SetFileName(filename);
       viewer->SetInputOverlay(reader->GetOutput();
+
       viewer->SetInputOverlay(reader->GetOutput();
 
   }
 
   }
  viewer->Build();
+
  viewer->Build();
  viewer->Update();
+
  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.
+
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.
 
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.
 
----
 
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;">
 
----
 
=[http://ucizelulaji.co.cc UNDER COSTRUCTION, PLEASE SEE THIS POST IN RESERVE COPY]=
 
----
 
=[http://ucizelulaji.co.cc CLICK HERE]=
 
----
 
</div>
 

Revision as of 18:30, 19 November 2010

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.