Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 576714da authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#552 The bug seems to stem from ComponentManager: the smart pointer was used...

#552 The bug seems to stem from ComponentManager: the smart pointer was used inside a std::function, and when it was a std::unique_ptr it led to a double deallocation. I'm a bit surprised the compiler let that pass in the first place.
parent 40c8b128
No related branches found
No related tags found
No related merge requests found
Showing
with 14 additions and 14 deletions
......@@ -24,7 +24,7 @@ namespace HappyHeart
{
ComponentManager::const_unique_ptr Create()
ComponentManager::const_shared_ptr Create()
{
return std::make_unique<Comp1>();
}
......
......@@ -23,7 +23,7 @@ namespace HappyHeart
{
ComponentManager::const_unique_ptr Create()
ComponentManager::const_shared_ptr Create()
{
return std::make_unique<Comp12>();
}
......
......@@ -23,7 +23,7 @@ namespace HappyHeart
{
ComponentManager::const_unique_ptr Create()
ComponentManager::const_shared_ptr Create()
{
return std::make_unique<Comp123>();
}
......
......@@ -23,7 +23,7 @@ namespace HappyHeart
{
ComponentManager::const_unique_ptr Create()
ComponentManager::const_shared_ptr Create()
{
return std::make_unique<Comp13>();
}
......
......@@ -23,7 +23,7 @@ namespace HappyHeart
{
ComponentManager::const_unique_ptr Create()
ComponentManager::const_shared_ptr Create()
{
return std::make_unique<Comp2>();
}
......
......@@ -24,7 +24,7 @@ namespace HappyHeart
{
ComponentManager::const_unique_ptr Create()
ComponentManager::const_shared_ptr Create()
{
return std::make_unique<Comp23>();
}
......
......@@ -23,7 +23,7 @@ namespace HappyHeart
{
ComponentManager::const_unique_ptr Create()
ComponentManager::const_shared_ptr Create()
{
return std::make_unique<Comp3>();
}
......
......@@ -24,7 +24,7 @@ namespace HappyHeart
{
ComponentManager::const_unique_ptr Create()
ComponentManager::const_shared_ptr Create()
{
return std::make_unique<CompNA>();
}
......
......@@ -27,7 +27,7 @@ namespace HappyHeart
//! Shared smart pointer.
using const_unique_ptr = std::unique_ptr<const ComponentManager>;
using const_shared_ptr = std::shared_ptr<const ComponentManager>;
//! Constructor.
explicit ComponentManager(const std::string& name, std::bitset<3> is_activated);
......
......@@ -109,7 +109,7 @@ namespace HappyHeart
//! variable concerned by this DirichletBoundaryCondition
const Unknown& unknown_;
ComponentManager::const_unique_ptr component_manager_ = nullptr;
ComponentManager::const_shared_ptr component_manager_ = nullptr;
/*!
* \brief List of dofs concerned by the boundary condition and their associated value.
......
......@@ -33,14 +33,14 @@ namespace HappyHeart
ComponentManager::const_unique_ptr ComponentFactory::CreateFromName(const std::string& component_name) const
ComponentManager::const_shared_ptr ComponentFactory::CreateFromName(const std::string& component_name) const
{
auto it = callbacks_.find(component_name);
if (it == callbacks_.cend())
throw ExceptionNS::Factory::UnregisteredName(component_name, "component", __FILE__, __LINE__);
ComponentManager::const_unique_ptr ret = it->second();
ComponentManager::const_shared_ptr ret = it->second();
return ret;
}
......
......@@ -40,7 +40,7 @@ namespace HappyHeart
//! Alias for a function which will create a 'Component'
using FunctionPrototype = std::function<ComponentManager::const_unique_ptr()>;
using FunctionPrototype = std::function<ComponentManager::const_shared_ptr()>;
/*!
* \brief Alias for call back.
......@@ -68,7 +68,7 @@ namespace HappyHeart
/*!
* \brief Create an object according to its name.
*/
ComponentManager::const_unique_ptr CreateFromName(const std::string& component_name) const;
ComponentManager::const_shared_ptr CreateFromName(const std::string& component_name) const;
//! Number of elements registered in the factory.
inline CallBack::size_type Nvariable() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment