diff --git a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.cpp b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.cpp index 56c54d9da54..90ac4caf386 100644 --- a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.cpp +++ b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.cpp @@ -115,9 +115,11 @@ FileMessageHandlerComponent::FileMessageHandlerComponent() : FileMessageHandlerComponent::~FileMessageHandlerComponent() { - MessageDispatcher::rmHandler(m_handler) ; - - delete m_handler ; + if (m_handler) + { + MessageDispatcher::rmHandler(m_handler) ; + delete m_handler ; + } } void FileMessageHandlerComponent::parse ( core::objectmodel::BaseObjectDescription* arg ) diff --git a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.h b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.h index cd2187d2aa9..b2d3f946f39 100644 --- a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.h +++ b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MessageHandlerComponent.h @@ -77,7 +77,7 @@ class SOFA_COMPONENT_SCENEUTILITY_API FileMessageHandlerComponent : public core: void parse ( core::objectmodel::BaseObjectDescription* arg ) override; Data d_filename ; ///< Name of the file into which the message will be saved in. - helper::logging::MessageHandler* m_handler ; + helper::logging::MessageHandler* m_handler { nullptr }; bool m_isValid ;