MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

Commit 8ff8c5d8 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1294 Singleton: change the destruction sequence to fix an issue observed with...

#1294 Singleton: change the destruction sequence to fix an issue observed with gcc in release mode where the underlying BasicRefFEltFactory destructor was called twice.
parent 1bbf6156
......@@ -63,9 +63,11 @@ namespace MoReFEM
template<class T>
class Singleton
{
public:
//! Convenient alias.
using self = Singleton<T>;
/*!
* \brief Call instance of the singleton.
*
......@@ -162,7 +164,7 @@ namespace MoReFEM
private:
//! Internal pointer to the actual instance.
static std::unique_ptr<T> instance_;
static T* instance_;
/*!
......
......@@ -23,7 +23,7 @@ namespace MoReFEM
template<class T>
std::unique_ptr<T> Singleton<T>::instance_ = nullptr;
T* Singleton<T>::instance_ = nullptr;
template<class T>
......@@ -37,7 +37,14 @@ namespace MoReFEM
template<class T>
void Singleton<T>::Destroy()
{
instance_ = nullptr;
// See http://codeofthedamned.com/index.php/unit-testing-a-singleton-in for an explanation about this...
if (!(!instance_))
{
self* buf = instance_;
instance_ = nullptr;
delete buf;
}
destroyed_ = true;
}
......@@ -86,8 +93,7 @@ namespace MoReFEM
void Singleton<T>::Create(Args&&... args)
{
assert(!instance_);
auto ptr = new T(std::forward<Args>(args)...);
instance_.reset(ptr);
instance_ = new T(std::forward<Args>(args)...);
int error_code = std::atexit(Destroy); // to destroy the singleton at the end of the program.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment