From 14c23e6bfd8ac1718d126d3fc8c7fa809d6d3bef Mon Sep 17 00:00:00 2001
From: Julien Michel <julien.michel@cnes.fr>
Date: Fri, 16 Feb 2018 16:31:29 +0100
Subject: [PATCH] BUG: Only call UpdateOutputData() if object has Source

---
 .../Core/ObjectList/include/otbImageList.h    |  2 ++
 .../Core/ObjectList/include/otbImageList.txx  | 21 +++++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/Modules/Core/ObjectList/include/otbImageList.h b/Modules/Core/ObjectList/include/otbImageList.h
index 611d84a47a..4cb77bddec 100644
--- a/Modules/Core/ObjectList/include/otbImageList.h
+++ b/Modules/Core/ObjectList/include/otbImageList.h
@@ -68,6 +68,8 @@ public:
     throw (itk::InvalidRequestedRegionError) ITK_OVERRIDE;
   void UpdateOutputData(void) ITK_OVERRIDE;
 
+  void SetRequestedRegion(const itk::DataObject * source);
+  
 protected:
   /** Constructor */
   ImageList() {};
diff --git a/Modules/Core/ObjectList/include/otbImageList.txx b/Modules/Core/ObjectList/include/otbImageList.txx
index 80b7276454..426a594027 100644
--- a/Modules/Core/ObjectList/include/otbImageList.txx
+++ b/Modules/Core/ObjectList/include/otbImageList.txx
@@ -35,7 +35,15 @@ ImageList<TImage>
   Superclass::UpdateOutputData();
   for (ConstIterator it = this->Begin(); it != this->End(); ++it)
     {
+    if (it.Get()->GetUpdateMTime() < it.Get()->GetPipelineMTime()
+        || it.Get()->GetDataReleased()
+        || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion())
+      {
+      if(it.Get()->GetSource())
+        {
         it.Get()->GetSource()->UpdateOutputData(it.Get());
+        }
+      }
     }
 }
 
@@ -52,6 +60,8 @@ ImageList<TImage>
         || it.Get()->GetDataReleased()
         || it.Get()->RequestedRegionIsOutsideOfTheBufferedRegion())
       {
+
+      std::cout<<"Requested region: "<<it.Get()<<" "<<it.Get()->GetRequestedRegion()<<std::endl;
       if (it.Get()->GetSource())
         {
         it.Get()->GetSource()->PropagateRequestedRegion(it.Get());
@@ -72,6 +82,17 @@ ImageList<TImage>
     }
   }
 
+template<class TImage>
+void
+ImageList<TImage>
+::SetRequestedRegion(const itk::DataObject * source)
+{
+  for (ConstIterator it = this->Begin(); it != this->End(); ++it)
+    {
+    it.Get()->SetRequestedRegion(source);
+    }
+}
+
 template <class TImage>
 void
 ImageList<TImage>
-- 
GitLab