From dc9012a9a3fba66c4bdceb4e286498cb7624fb52 Mon Sep 17 00:00:00 2001 From: Kyle Sunderland Date: Fri, 26 Oct 2018 18:07:54 -0400 Subject: [PATCH] BUG: Fix failing vtkMRMLStreamingVolumeNode test and memory leak - vtkMRMLStreamingVolumeNodeTest1.cxx was previously failing due to missing scene - Fixed Memory leak vtkStreamingVolumeCodec within vtkMRMLStreamingVolumeNode where vtkSmartPointer::Take was not used with the factory method. - Fix compile warning for unused parameter in vtkRawRGBVolumeCodec --- Libs/MRML/Core/Testing/vtkMRMLStreamingVolumeNodeTest1.cxx | 3 +++ Libs/MRML/Core/vtkMRMLStreamingVolumeNode.cxx | 2 +- Libs/vtkAddon/vtkRawRGBVolumeCodec.h | 4 ++++ Libs/vtkAddon/vtkStreamingVolumeCodec.h | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Libs/MRML/Core/Testing/vtkMRMLStreamingVolumeNodeTest1.cxx b/Libs/MRML/Core/Testing/vtkMRMLStreamingVolumeNodeTest1.cxx index bcdfcfc37..8c42949b7 100644 --- a/Libs/MRML/Core/Testing/vtkMRMLStreamingVolumeNodeTest1.cxx +++ b/Libs/MRML/Core/Testing/vtkMRMLStreamingVolumeNodeTest1.cxx @@ -20,11 +20,14 @@ Care Ontario. // MRML includes #include "vtkMRMLCoreTestingMacros.h" +#include "vtkMRMLScene.h" #include "vtkMRMLStreamingVolumeNode.h" int vtkMRMLStreamingVolumeNodeTest1(int , char * [] ) { vtkNew node1; + vtkNew scene; + scene->AddNode(node1); EXERCISE_ALL_BASIC_MRML_METHODS(node1.GetPointer()); int width = 10; diff --git a/Libs/MRML/Core/vtkMRMLStreamingVolumeNode.cxx b/Libs/MRML/Core/vtkMRMLStreamingVolumeNode.cxx index 93284279e..eb56eb03f 100644 --- a/Libs/MRML/Core/vtkMRMLStreamingVolumeNode.cxx +++ b/Libs/MRML/Core/vtkMRMLStreamingVolumeNode.cxx @@ -155,7 +155,7 @@ vtkStreamingVolumeCodec* vtkMRMLStreamingVolumeNode::GetCodec() (this->Codec && this->Codec->GetFourCC() != this->GetCodecFourCC())) { - this->Codec = vtkStreamingVolumeCodecFactory::GetInstance()->CreateCodecByFourCC(this->GetCodecFourCC()); + this->Codec = vtkSmartPointer::Take(vtkStreamingVolumeCodecFactory::GetInstance()->CreateCodecByFourCC(this->GetCodecFourCC())); } return this->Codec; } diff --git a/Libs/vtkAddon/vtkRawRGBVolumeCodec.h b/Libs/vtkAddon/vtkRawRGBVolumeCodec.h index 7dad34bc1..a7cab25b3 100644 --- a/Libs/vtkAddon/vtkRawRGBVolumeCodec.h +++ b/Libs/vtkAddon/vtkRawRGBVolumeCodec.h @@ -51,6 +51,10 @@ protected: /// There are no parameters to update within this codec virtual bool UpdateParameterInternal(std::string vtkNotUsed(parameterValue), std::string vtkNotUsed(parameterName)) { return false; }; + /// Return the codec parameter description + /// There are no parameters to update within this codec + virtual std::string GetParameterDescription(std::string vtkNotUsed(parameterName)) { return ""; }; + private: vtkRawRGBVolumeCodec(const vtkRawRGBVolumeCodec&); void operator=(const vtkRawRGBVolumeCodec&); diff --git a/Libs/vtkAddon/vtkStreamingVolumeCodec.h b/Libs/vtkAddon/vtkStreamingVolumeCodec.h index 4f581f306..b32aeeef5 100644 --- a/Libs/vtkAddon/vtkStreamingVolumeCodec.h +++ b/Libs/vtkAddon/vtkStreamingVolumeCodec.h @@ -93,7 +93,7 @@ public: /// Get parameter description as a string /// \param parameterName String containing the name of the parameter /// Returns the description of the parameter as a string, and returns an empty string if the parameter name is invalid - virtual std::string GetParameterDescription(std::string parameterName) { return ""; }; + virtual std::string GetParameterDescription(std::string parameterName) = 0; /// Set a parameter for the codec /// \param parameterName String containing the name of the parameter -- GitLab