浏览代码

Clear image mapper input when RenderWindowItem is destroyed

Since the ImageActor is still in the renderer even after the
light box mode has changed, a paint event can lead to a Render
being called even though the input pipeline has already
been torn down.  This can lead to the image being rendered
with null data in the vtkImageData, and then a crash as
described in http://na-mic.org/Bug/view.php?id=2512
Steve Pieper 12 年之前
父节点
当前提交
691a9542e2
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7 4
      Libs/Visualization/VTK/Core/vtkLightBoxRendererManager.cpp

+ 7 - 4
Libs/Visualization/VTK/Core/vtkLightBoxRendererManager.cpp

@@ -59,6 +59,7 @@ class RenderWindowItem
 public:
   RenderWindowItem(const double rendererBackgroundColor[3], const double highlightedBoxColor[3],
                    double colorWindow, double colorLevel);
+  ~RenderWindowItem();
   void SetViewport(double xMin, double yMin, double viewportWidth, double viewportHeight);
 
   /// Create the actor supporing the image mapper
@@ -95,6 +96,12 @@ RenderWindowItem::RenderWindowItem(const double rendererBackgroundColor[3],
 }
 
 //-----------------------------------------------------------------------------
+RenderWindowItem::~RenderWindowItem()
+{
+  this->ImageMapper->SetInput(0);
+}
+
+//-----------------------------------------------------------------------------
 void RenderWindowItem::SetViewport(double xMin, double yMin,
                                    double viewportWidth, double viewportHeight)
 {
@@ -606,8 +613,6 @@ void vtkLightBoxRendererManager::SetRenderWindowLayout(int rowCount, int columnC
     - static_cast<int>(this->Internal->RenderWindowItemList.size());
   if (extraItem > 0)
     {
-    //std::cout << "Creating " << extraItem << " RenderWindowItem";
-
     // Create extra RenderWindowItem(s)
     while(extraItem > 0)
       {
@@ -623,8 +628,6 @@ void vtkLightBoxRendererManager::SetRenderWindowLayout(int rowCount, int columnC
     }
   else
     {
-    //std::cout << "Removing " << extraItem << " RenderWindowItem";
-
     // Remove extra RenderWindowItem(s)
     extraItem = extraItem >= 0 ? extraItem : -extraItem; // Compute Abs
     while(extraItem > 0)