From 42bfdd5a4ca8c51211dd2ee2c42cc070a064b925 Mon Sep 17 00:00:00 2001 From: Hans Johnson Date: Sat, 14 Dec 2019 07:59:02 -0600 Subject: [PATCH] BUG: Set 'GetDataObject' function signature to const When throwing exceptions, getting the data object pointer should be always be constant. --- Modules/Core/Common/include/itkDataObject.h | 8 +++++--- Modules/Core/Common/src/itkDataObject.cxx | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Modules/Core/Common/include/itkDataObject.h b/Modules/Core/Common/include/itkDataObject.h index ea746fd8643..ebe4245fd2c 100644 --- a/Modules/Core/Common/include/itkDataObject.h +++ b/Modules/Core/Common/include/itkDataObject.h @@ -77,12 +77,14 @@ class ITKCommon_EXPORT DataObjectError : public ExceptionObject void SetDataObject(DataObject * dobj) noexcept; - /** Get the data object that is throwing this exception. */ - DataObject * - GetDataObject() noexcept; + /** Get the data object that is throwing this exception. */ const DataObject * GetDataObject() const noexcept; +#if !defined(ITK_LEGACY_REMOVE) + DataObject * + GetDataObject() noexcept; +#endif protected: /** Print exception information. This method can be overridden by diff --git a/Modules/Core/Common/src/itkDataObject.cxx b/Modules/Core/Common/src/itkDataObject.cxx index 85feb624968..7ace5282117 100644 --- a/Modules/Core/Common/src/itkDataObject.cxx +++ b/Modules/Core/Common/src/itkDataObject.cxx @@ -64,11 +64,13 @@ DataObjectError ::SetDataObject(DataObject * dobj) noexcept m_DataObject = dobj; } +#if !defined(ITK_LEGACY_REMOVE) DataObject * DataObjectError ::GetDataObject() noexcept { return m_DataObject; } +#endif const DataObject * DataObjectError ::GetDataObject() const noexcept