changeset 1639:5cdc5b98f14d

cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 10 Nov 2020 16:41:11 +0100
parents 754ef576d945
children 52b8b96cb55f
files Applications/Resources/RunCppCheck.sh OrthancStone/Sources/OpenGL/OpenGLProgram.cpp OrthancStone/Sources/OpenGL/OpenGLProgram.h OrthancStone/Sources/Scene2D/GrayscaleWindowingSceneTracker.cpp OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp OrthancStone/Sources/Toolbox/OsiriX/AngleAnnotation.h OrthancStone/Sources/Toolbox/OsiriX/IntegerValue.h OrthancStone/Sources/Toolbox/OsiriX/RealValue.h OrthancStone/Sources/Toolbox/OsiriX/StringValue.h OrthancStone/Sources/Toolbox/OsiriX/TextAnnotation.h
diffstat 10 files changed, 42 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Resources/RunCppCheck.sh	Tue Nov 10 16:26:47 2020 +0100
+++ b/Applications/Resources/RunCppCheck.sh	Tue Nov 10 16:41:11 2020 +0100
@@ -29,13 +29,12 @@
 
 cat <<EOF > /tmp/cppcheck-suppressions.txt
 stlFindInsert:../../Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h
-stlFindInsert:../../Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp:685
+stlFindInsert:../../Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp:703
 unpreciseMathCall:../../OrthancStone/Sources/Scene2D/Internals/CairoFloatTextureRenderer.cpp
 unpreciseMathCall:../../OrthancStone/Sources/Scene2D/LookupTableTextureSceneLayer.cpp
 unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:143
 unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:197
 unusedFunction
-useInitializationList:../../OrthancStone/Sources/OpenGL/OpenGLProgram.cpp:36
 EOF
 
 ${CPPCHECK} --enable=all --quiet --std=c++11 \
@@ -58,7 +57,7 @@
             -DORTHANC_ENABLE_OPENGL=1 \
             -DORTHANC_ENABLE_PKCS11=0 \
             -DORTHANC_ENABLE_PNG=1 \
-            -DORTHANC_ENABLE_PUGIXML=0 \
+            -DORTHANC_ENABLE_PUGIXML=1 \
             -DORTHANC_ENABLE_SDL=1 \
             -DORTHANC_ENABLE_SSL=1 \
             -DORTHANC_ENABLE_THREADS=1 \
@@ -83,5 +82,6 @@
             -i ../../Applications/StoneWebViewer/Plugin/i \
             -i ../../Applications/StoneWebViewer/WebAssembly/StoneModule/i \
             -i ../../Applications/StoneWebViewer/WebAssembly/i \
+            -i ../../Applications/StoneWebViewer/WebAssembly/debug/ \
             \
             2>&1
--- a/OrthancStone/Sources/OpenGL/OpenGLProgram.cpp	Tue Nov 10 16:26:47 2020 +0100
+++ b/OrthancStone/Sources/OpenGL/OpenGLProgram.cpp	Tue Nov 10 16:41:11 2020 +0100
@@ -35,9 +35,9 @@
   namespace OpenGL
   {
     OpenGLProgram::OpenGLProgram(OpenGL::IOpenGLContext& context) :
-      context_(context)
+      context_(context),
+      program_(glCreateProgram())
     {
-      program_ = glCreateProgram();
       ORTHANC_OPENGL_CHECK("glCreateProgram");
 
       if (program_ == 0)
--- a/OrthancStone/Sources/OpenGL/OpenGLProgram.h	Tue Nov 10 16:26:47 2020 +0100
+++ b/OrthancStone/Sources/OpenGL/OpenGLProgram.h	Tue Nov 10 16:41:11 2020 +0100
@@ -35,6 +35,10 @@
 
     class OpenGLProgram : public boost::noncopyable
     {
+    private:
+      OpenGL::IOpenGLContext& context_;
+      GLuint                  program_;
+
     public:
       // WARNING: A global OpenGL context must be active to create this object!
       // the context is only passed so that it can be checked for loss
@@ -52,10 +56,6 @@
       GLint GetUniformLocation(const std::string& name);
 
       GLint GetAttributeLocation(const std::string& name);
-
-    private:
-      GLuint  program_;
-      OpenGL::IOpenGLContext& context_;
     };
   }
 }
--- a/OrthancStone/Sources/Scene2D/GrayscaleWindowingSceneTracker.cpp	Tue Nov 10 16:26:47 2020 +0100
+++ b/OrthancStone/Sources/Scene2D/GrayscaleWindowingSceneTracker.cpp	Tue Nov 10 16:41:11 2020 +0100
@@ -117,24 +117,28 @@
     if (canvasWidth > 3 &&
         canvasHeight > 3)
     {
-      boost::weak_ptr<IViewport> viewport = viewport_.lock();
-      GrayscaleLayerAccessor accessor(viewport, layerIndex_);
+      boost::shared_ptr<IViewport> locked = viewport_.lock();
+
+      if (locked)
+      {
+        GrayscaleLayerAccessor accessor(locked, layerIndex_);
       
-      if (accessor.IsValid())
-      {
-        FloatTextureSceneLayer& layer = accessor.GetLayer();
-        
-        layer.GetWindowing(originalCenter_, originalWidth_);
+        if (accessor.IsValid())
+        {
+          FloatTextureSceneLayer& layer = accessor.GetLayer();
         
-        float minValue, maxValue;
-        layer.GetRange(minValue, maxValue);
+          layer.GetWindowing(originalCenter_, originalWidth_);
+        
+          float minValue, maxValue;
+          layer.GetRange(minValue, maxValue);
         
-        normalization_ = (maxValue - minValue) / static_cast<double>(std::min(canvasWidth, canvasHeight) - 1);
-        active_ = true;
-      }
-      else
-      {
-        LOG(INFO) << "Cannot create GrayscaleWindowingSceneTracker on a non-float texture";
+          normalization_ = (maxValue - minValue) / static_cast<double>(std::min(canvasWidth, canvasHeight) - 1);
+          active_ = true;
+        }
+        else
+        {
+          LOG(INFO) << "Cannot create GrayscaleWindowingSceneTracker on a non-float texture";
+        }
       }
     }
   }
--- a/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp	Tue Nov 10 16:26:47 2020 +0100
+++ b/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp	Tue Nov 10 16:41:11 2020 +0100
@@ -125,7 +125,14 @@
     }
 
     // Must be AFTER setting "numberOfFrames_"
-    ExtractFrameOffsets(frameOffsets_, dicom, numberOfFrames_);
+    if (numberOfFrames_ > 1)
+    {
+      ExtractFrameOffsets(frameOffsets_, dicom, numberOfFrames_);
+    }
+    else
+    {
+      frameOffsets_.resize(0);
+    }
 
     if (sopClassUid_ == SopClassUid_RTDose)
     {
--- a/OrthancStone/Sources/Toolbox/OsiriX/AngleAnnotation.h	Tue Nov 10 16:26:47 2020 +0100
+++ b/OrthancStone/Sources/Toolbox/OsiriX/AngleAnnotation.h	Tue Nov 10 16:41:11 2020 +0100
@@ -39,7 +39,7 @@
       Vector  b_;
 
     public:
-      AngleAnnotation(const DictionaryValue& dict);
+      explicit AngleAnnotation(const DictionaryValue& dict);
 
       virtual Type GetType() const ORTHANC_OVERRIDE
       {
--- a/OrthancStone/Sources/Toolbox/OsiriX/IntegerValue.h	Tue Nov 10 16:26:47 2020 +0100
+++ b/OrthancStone/Sources/Toolbox/OsiriX/IntegerValue.h	Tue Nov 10 16:41:11 2020 +0100
@@ -39,7 +39,7 @@
       int64_t  value_;
 
     public:
-      IntegerValue(int64_t value) :
+      explicit IntegerValue(int64_t value) :
         value_(value)
       {
       }
--- a/OrthancStone/Sources/Toolbox/OsiriX/RealValue.h	Tue Nov 10 16:26:47 2020 +0100
+++ b/OrthancStone/Sources/Toolbox/OsiriX/RealValue.h	Tue Nov 10 16:41:11 2020 +0100
@@ -37,7 +37,7 @@
       double  value_;
 
     public:
-      RealValue(double value) :
+      explicit RealValue(double value) :
         value_(value)
       {
       }
--- a/OrthancStone/Sources/Toolbox/OsiriX/StringValue.h	Tue Nov 10 16:26:47 2020 +0100
+++ b/OrthancStone/Sources/Toolbox/OsiriX/StringValue.h	Tue Nov 10 16:41:11 2020 +0100
@@ -40,7 +40,7 @@
       std::string  value_;
 
     public:
-      StringValue(const std::string& value) :
+      explicit StringValue(const std::string& value) :
         value_(value)
       {
       }
--- a/OrthancStone/Sources/Toolbox/OsiriX/TextAnnotation.h	Tue Nov 10 16:26:47 2020 +0100
+++ b/OrthancStone/Sources/Toolbox/OsiriX/TextAnnotation.h	Tue Nov 10 16:41:11 2020 +0100
@@ -37,8 +37,8 @@
       Vector  center_;
 
     public:
-      TextAnnotation(const DictionaryValue& dict);
-
+      explicit TextAnnotation(const DictionaryValue& dict);
+      
       virtual Type GetType() const ORTHANC_OVERRIDE
       {
         return Type_Text;