Commit a396e891 authored by Ronan's avatar Ronan
Browse files

fix(Singleton): delete properly instance at program termination

parent 3c446b76
......@@ -32,8 +32,8 @@ using namespace LinphonePrivate;
class Cpim::GenericHeaderPrivate : public HeaderPrivate {
public:
GenericHeaderPrivate() : parameters(make_shared< list< pair<string, string> > >()){
}
GenericHeaderPrivate () : parameters(make_shared<list<pair<string, string> > >()) {}
string name;
shared_ptr<list<pair<string, string> > > parameters;
};
......
......@@ -30,8 +30,10 @@ namespace LinphonePrivate {
virtual ~Singleton () = default;
static T *getInstance () {
if (!mInstance)
if (!mInstance) {
mInstance = new T();
static SingletonDeleter deleter;
}
return mInstance;
}
......@@ -39,6 +41,12 @@ namespace LinphonePrivate {
explicit Singleton (ObjectPrivate &p) : Object(p) {}
private:
struct SingletonDeleter {
~SingletonDeleter () {
delete mInstance;
}
};
static T *mInstance;
L_DISABLE_COPY(Singleton);
......
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