Skip to content

Commit

Permalink
BUG: Set 'GetDataObject' function signature to const
Browse files Browse the repository at this point in the history
When throwing exceptions, getting the data object pointer
should be always be constant.
  • Loading branch information
hjmjohnson authored and dzenanz committed Dec 14, 2019
1 parent c7fd5bd commit 42bfdd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Modules/Core/Common/include/itkDataObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Common/src/itkDataObject.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 42bfdd5

Please sign in to comment.