changeset 1258:9c20ae049669

more logs to debug exceptions in Render
author Alain Mazy <alain@mazy.be>
date Tue, 14 Jan 2020 15:22:10 +0100
parents 6af941a68472
children 69177b10e2b9
files Framework/Radiography/RadiographyScene.cpp Framework/Radiography/RadiographyWidget.cpp
diffstat 2 files changed, 27 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Radiography/RadiographyScene.cpp	Tue Jan 14 12:05:01 2020 +0100
+++ b/Framework/Radiography/RadiographyScene.cpp	Tue Jan 14 15:22:10 2020 +0100
@@ -564,11 +564,24 @@
     // Render layers in the background-to-foreground order
     for (size_t index = 0; index < nextLayerIndex_; index++)
     {
-      Layers::const_iterator it = layers_.find(index);
-      if (it != layers_.end())
+      try
       {
-        assert(it->second != NULL);
-        it->second->Render(buffer, viewTransform, interpolation, windowingCenter_, windowingWidth_, applyWindowing);
+        Layers::const_iterator it = layers_.find(index);
+        if (it != layers_.end())
+        {
+          assert(it->second != NULL);
+          it->second->Render(buffer, viewTransform, interpolation, windowingCenter_, windowingWidth_, applyWindowing);
+        }
+      }
+      catch (Orthanc::OrthancException& ex)
+      {
+        LOG(ERROR) << "RadiographyScene::Render: " << index << ", OrthancException: " << ex.GetDetails();
+        throw ex; // rethrow because we want it to crash to see there's a problem !
+      }
+      catch (...)
+      {
+        LOG(ERROR) << "RadiographyScene::Render: " << index << ", unkown exception: ";
+        throw; // rethrow because we want it to crash to see there's a problem !
       }
     }
   }
--- a/Framework/Radiography/RadiographyWidget.cpp	Tue Jan 14 12:05:01 2020 +0100
+++ b/Framework/Radiography/RadiographyWidget.cpp	Tue Jan 14 15:22:10 2020 +0100
@@ -76,6 +76,11 @@
     {
       floatBuffer_.reset(new Orthanc::Image(
         Orthanc::PixelFormat_Float32, width, height, false));
+
+      if (floatBuffer_.get() == NULL)
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory, "RadiographyWidget::RenderInternal: unable to allocate float buffer");
+      }
     }
 
     if (cairoBuffer_.get() == NULL ||
@@ -83,6 +88,11 @@
         cairoBuffer_->GetHeight() != height)
     {
       cairoBuffer_.reset(new CairoSurface(width, height, false /* no alpha */));
+
+      if (cairoBuffer_.get() == NULL)
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_NotEnoughMemory, "RadiographyWidget::RenderInternal: unable to allocate cairo buffer");
+      }
     }
 
     RenderBackground(*floatBuffer_, 0.0, 65535.0);