Commit 2deb5890 authored by Tristan Matthews's avatar Tristan Matthews

* #9774: make sure sipvoiplink is destroyed before accounts are unloaded

parent 018f1ab5
......@@ -130,6 +130,7 @@ void ManagerImpl::terminate()
saveConfig();
SIPVoIPLink::destroy();
// Unload account map AFTER destroying
// the SIPVoIPLink, the link still needs the accounts for pjsip cleanup
unloadAccountMap();
......
/*
* Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Savoir-Faire Linux Inc.
*
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
* Author: Yun Liu <yun.liu@savoirfairelinux.com>
* Author: Pierre-Luc Bacon <pierre-luc.bacon@savoirfairelinux.com>
......@@ -65,11 +64,13 @@
#include <istream>
#include <utility> // for std::pair
#include <map>
using namespace sfl;
SIPVoIPLink *SIPVoIPLink::instance_ = 0;
bool SIPVoIPLink::destroyed_ = false;
namespace {
/** A map to retreive SFLphone internal call id
......@@ -507,8 +508,17 @@ SIPVoIPLink::~SIPVoIPLink()
SIPVoIPLink* SIPVoIPLink::instance()
{
static SIPVoIPLink instance_;
return &instance_;
assert(!destroyed_);
if (!instance_)
instance_ = new SIPVoIPLink;
return instance_;
}
void SIPVoIPLink::destroy()
{
delete instance_;
destroyed_ = true;
instance_ = 0;
}
// Called from EventThread::run (not main thread)
......
......@@ -71,6 +71,11 @@ class SIPVoIPLink : public VoIPLink {
*/
static SIPVoIPLink* instance();
/**
* Destroy the singleton instance
*/
static void destroy();
/**
* Event listener. Each event send by the call manager is received and handled from here
*/
......@@ -248,6 +253,8 @@ class SIPVoIPLink : public VoIPLink {
EventThread evThread_;
friend class SIPTest;
static bool destroyed_;
static SIPVoIPLink *instance_;
};
#endif // SIPVOIPLINK_H_
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