changeset 94:7b14c12a3be5 wasm

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 May 2017 18:03:30 +0200
parents 5945e81734a3
children f47349f4815c
files Applications/Samples/SingleFrameApplication.h Framework/Layers/FrameRenderer.cpp Framework/Layers/LayerSourceBase.cpp Framework/Toolbox/OrthancSlicesLoader.cpp
diffstat 4 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Samples/SingleFrameApplication.h	Mon May 29 17:28:31 2017 +0200
+++ b/Applications/Samples/SingleFrameApplication.h	Mon May 29 18:03:30 2017 +0200
@@ -174,7 +174,7 @@
 
         std::auto_ptr<LayerWidget> widget(new LayerWidget);
 
-#if 0
+#if 1
         std::auto_ptr<OrthancFrameLayerSource> layer
           (new OrthancFrameLayerSource(context.GetWebService(), instance, frame));
         layer->Register(*this);
--- a/Framework/Layers/FrameRenderer.cpp	Mon May 29 17:28:31 2017 +0200
+++ b/Framework/Layers/FrameRenderer.cpp	Mon May 29 18:03:30 2017 +0200
@@ -138,7 +138,7 @@
   bool FrameRenderer::RenderLayer(CairoContext& context,
                                   const ViewportGeometry& view,
                                   const SliceGeometry& viewportSlice)
-  {
+  {    
     if (!style_.visible_)
     {
       return true;
--- a/Framework/Layers/LayerSourceBase.cpp	Mon May 29 17:28:31 2017 +0200
+++ b/Framework/Layers/LayerSourceBase.cpp	Mon May 29 18:03:30 2017 +0200
@@ -39,6 +39,10 @@
         layer_(layer),
         slice_(slice)
       {
+        if (layer == NULL)
+        {
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
+        }
       }
 
       void operator() (ILayerSource::IObserver& observer,
@@ -72,11 +76,6 @@
   void LayerSourceBase::NotifyLayerReady(ILayerRenderer* layer,
                                          const Slice& slice)
   {
-    if (layer == NULL)
-    {
-      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
-    }
-
     LayerReadyFunctor functor(layer, slice);
     observers_.Notify(*this, functor);
   }
--- a/Framework/Toolbox/OrthancSlicesLoader.cpp	Mon May 29 17:28:31 2017 +0200
+++ b/Framework/Toolbox/OrthancSlicesLoader.cpp	Mon May 29 18:03:30 2017 +0200
@@ -376,7 +376,7 @@
     {
       NotifySliceImageError(operation);
       return;
-    }          
+    }
 
     bool isSigned = false;
     bool isStretched = info["Stretched"].asBool();
@@ -385,7 +385,8 @@
     {
       if (info["IsSigned"].type() != Json::booleanValue)
       {
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+        NotifySliceImageError(operation);
+        return;
       }          
       else
       {
@@ -397,6 +398,7 @@
     Orthanc::Toolbox::DecodeBase64(jpeg, info["PixelData"].asString());
 
     std::auto_ptr<Orthanc::JpegReader> reader(new Orthanc::JpegReader);
+
     try
     {
       reader->ReadFromMemory(jpeg);
@@ -482,6 +484,8 @@
     float offset = static_cast<float>(stretchLow) / scaling;
       
     Orthanc::ImageProcessing::Convert(*image, *reader);
+    reader.reset(NULL);
+    
     Orthanc::ImageProcessing::ShiftScale(*image, offset, scaling);
 
     NotifySliceImageSuccess(operation, image.release());
@@ -625,7 +629,7 @@
     
     // This requires the official Web viewer plugin to be installed!
     const Slice& slice = GetSlice(index);
-    std::string uri = ("web-viewer/instances/jpeg" + 
+    std::string uri = ("/web-viewer/instances/jpeg" + 
                        boost::lexical_cast<std::string>(value) + 
                        "-" + slice.GetOrthancInstanceId() + "_" + 
                        boost::lexical_cast<std::string>(slice.GetFrame()));