mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 08:39:20 +00:00
fix(Singleton): delete properly instance at program termination
This commit is contained in:
parent
3c446b7695
commit
a396e8919a
2 changed files with 11 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue