# HG changeset patch # User Sebastien Jodogne # Date 1600705714 -7200 # Node ID 32e0c007789d32c4d46fd9dc8a300207a4d7368e # Parent 1b30393849720b3f93a743c74d8ea59339221fc9 cppcheck diff -r 1b3039384972 -r 32e0c007789d Applications/Samples/Common/RtViewerApp.cpp --- a/Applications/Samples/Common/RtViewerApp.cpp Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/Common/RtViewerApp.cpp Mon Sep 21 18:28:34 2020 +0200 @@ -74,12 +74,12 @@ return geometry; } - RtViewerApp::RtViewerApp() - : undoStack_(new UndoStack) + RtViewerApp::RtViewerApp() : + undoStack_(new UndoStack), + // Create the volumes that will be filled later on + ctVolume_(boost::make_shared()), + doseVolume_(boost::make_shared()) { - // Create the volumes that will be filled later on - ctVolume_ = boost::make_shared(); - doseVolume_ = boost::make_shared(); } boost::shared_ptr RtViewerApp::Create() diff -r 1b3039384972 -r 32e0c007789d Applications/Samples/Common/RtViewerView.cpp --- a/Applications/Samples/Common/RtViewerView.cpp Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/Common/RtViewerView.cpp Mon Sep 21 18:28:34 2020 +0200 @@ -74,7 +74,7 @@ Scene2D& scene = controller.GetScene(); // do not try to use stuff too early! - OrthancStone::ICompositor& compositor = lock->GetCompositor(); + const OrthancStone::ICompositor& compositor = lock->GetCompositor(); std::stringstream msg; @@ -262,8 +262,8 @@ compositor.SetFont(1, ttf, FONT_SIZE_1, Orthanc::Encoding_Latin1); } - void RtViewerView::SetInfoDisplayMessage( - std::string key, std::string value) + void RtViewerView::SetInfoDisplayMessage(const std::string& key, + const std::string& value) { if (value == "") infoTextMap_.erase(key); diff -r 1b3039384972 -r 32e0c007789d Applications/Samples/Common/RtViewerView.h --- a/Applications/Samples/Common/RtViewerView.h Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/Common/RtViewerView.h Mon Sep 21 18:28:34 2020 +0200 @@ -108,7 +108,8 @@ } private: - void SetInfoDisplayMessage(std::string key, std::string value); + void SetInfoDisplayMessage(const std::string& key, + const std::string& value); boost::shared_ptr GetApp(); boost::shared_ptr CreateViewport(const std::string& canvasId); void DisplayInfoText(); diff -r 1b3039384972 -r 32e0c007789d Applications/Samples/Sdl/RtViewer/RtViewerSdl.cpp --- a/Applications/Samples/Sdl/RtViewer/RtViewerSdl.cpp Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/Sdl/RtViewer/RtViewerSdl.cpp Mon Sep 21 18:28:34 2020 +0200 @@ -208,7 +208,7 @@ { std::unique_ptr lock(viewport_->Lock()); ViewportController& controller = lock->GetController(); - Scene2D& scene = controller.GetScene(); + const Scene2D& scene = controller.GetScene(); std::string ttf; Orthanc::EmbeddedResources::GetFileResource(ttf, Orthanc::EmbeddedResources::UBUNTU_FONT); @@ -269,28 +269,33 @@ { std::vector sdlEvents; std::map userEventsMap; - SDL_Event sdlEvent; - // FIRST: collect all pending events - while (SDL_PollEvent(&sdlEvent) != 0) { - if ( (sdlEvent.type >= SDL_USEREVENT) && - (sdlEvent.type < SDL_LASTEVENT) ) + SDL_Event sdlEvent; + + // FIRST: collect all pending events + while (SDL_PollEvent(&sdlEvent) != 0) { - // we don't want to have multiple refresh events , - // and since every refresh event is a user event with a special type, - // we use a map - userEventsMap[sdlEvent.type] = sdlEvent; - } - else - { - sdlEvents.push_back(sdlEvent); + if ( (sdlEvent.type >= SDL_USEREVENT) && + (sdlEvent.type < SDL_LASTEVENT) ) + { + // we don't want to have multiple refresh events , + // and since every refresh event is a user event with a special type, + // we use a map + userEventsMap[sdlEvent.type] = sdlEvent; + } + else + { + sdlEvents.push_back(sdlEvent); + } } } // SECOND: add all user events to sdlEvents for (std::map::const_iterator it = userEventsMap.begin(); it != userEventsMap.end(); ++it) + { sdlEvents.push_back(it->second); + } // now process the events for (std::vector::const_iterator it = sdlEvents.begin(); it != sdlEvents.end(); ++it) diff -r 1b3039384972 -r 32e0c007789d Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h --- a/Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h Mon Sep 21 18:28:34 2020 +0200 @@ -191,10 +191,10 @@ IWebViewerLoadersObserver* observer) : context_(context), observer_(observer), - loadThumbnails_(false) + loadThumbnails_(false), + loadedSeries_(boost::make_shared(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID)), + loadedStudies_(boost::make_shared(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID)) { - loadedSeries_ = boost::make_shared(Orthanc::DICOM_TAG_SERIES_INSTANCE_UID); - loadedStudies_ = boost::make_shared(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID); } static Orthanc::IDynamicObject* CreatePayload(Type type) diff -r 1b3039384972 -r 32e0c007789d Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Mon Sep 21 18:13:52 2020 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Mon Sep 21 18:28:34 2020 +0200 @@ -151,7 +151,7 @@ boost::shared_ptr thumbnailsLoader_; boost::shared_ptr metadataLoader_; - ResourcesLoader(const OrthancStone::DicomSource& source) : + explicit ResourcesLoader(const OrthancStone::DicomSource& source) : source_(source), pending_(0), studies_(new OrthancStone::LoadedDicomResources(Orthanc::DICOM_TAG_STUDY_INSTANCE_UID)), @@ -385,7 +385,7 @@ assert(image != NULL); } - virtual size_t GetMemoryUsage() const + virtual size_t GetMemoryUsage() const ORTHANC_OVERRIDE { assert(image_.get() != NULL); return (image_->GetBytesPerPixel() * image_->GetPitch() * image_->GetHeight()); @@ -705,7 +705,7 @@ } public: - SeriesCursor(size_t framesCount) : + explicit SeriesCursor(size_t framesCount) : framesCount_(framesCount), currentFrame_(framesCount / 2), // Start at the middle frame isCircular_(false), @@ -792,12 +792,14 @@ OrthancStone::Extent2D extent_; public: - FrameGeometry() : - isValid_(false) + explicit FrameGeometry() : + isValid_(false), + pixelSpacingX_(1), + pixelSpacingY_(1) { } - FrameGeometry(const Orthanc::DicomMap& tags) : + explicit FrameGeometry(const Orthanc::DicomMap& tags) : isValid_(false), coordinates_(tags) { @@ -945,7 +947,7 @@ boost::shared_ptr viewport_; public: - ICommand(boost::shared_ptr viewport) : + explicit ICommand(boost::shared_ptr viewport) : viewport_(viewport) { if (viewport == NULL) @@ -983,7 +985,7 @@ class SetDefaultWindowingCommand : public ICommand { public: - SetDefaultWindowingCommand(boost::shared_ptr viewport) : + explicit SetDefaultWindowingCommand(boost::shared_ptr viewport) : ICommand(viewport) { } diff -r 1b3039384972 -r 32e0c007789d OrthancStone/Resources/RunCppCheck.sh --- a/OrthancStone/Resources/RunCppCheck.sh Mon Sep 21 18:13:52 2020 +0200 +++ b/OrthancStone/Resources/RunCppCheck.sh Mon Sep 21 18:28:34 2020 +0200 @@ -9,16 +9,19 @@ fi cat < /tmp/cppcheck-suppressions.txt +stlFindInsert:../../Applications/Samples/WebAssembly/SingleFrameViewer/SingleFrameViewerApplication.h +stlFindInsert:../../Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp:658 unpreciseMathCall:../../OrthancStone/Sources/Scene2D/Internals/CairoFloatTextureRenderer.cpp unpreciseMathCall:../../OrthancStone/Sources/Scene2D/LookupTableTextureSceneLayer.cpp +unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:135 +unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:193 unusedFunction useInitializationList:../../OrthancStone/Sources/OpenGL/OpenGLProgram.cpp:36 -unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:135 -unreadVariable:../../OrthancStone/Sources/Viewport/SdlViewport.cpp:193 EOF ${CPPCHECK} --enable=all --quiet --std=c++11 \ --suppressions-list=/tmp/cppcheck-suppressions.txt \ + -DHAS_ORTHANC_EXCEPTION=1 \ -DORTHANC_BUILDING_FRAMEWORK_LIBRARY=1 \ -DORTHANC_ENABLE_BASE64=1 \ -DORTHANC_ENABLE_CIVETWEB=0 \ @@ -46,9 +49,12 @@ -D__GNUC__ \ -D__cplusplus=201103 \ -D__linux__ \ + -DEM_ASM \ -UNDEBUG \ -I/home/jodogne/Subversion/orthanc/OrthancFramework/Sources \ \ ../../OrthancStone/Sources \ + ../../Applications/Samples \ + ../../Applications/StoneWebViewer \ \ 2>&1