diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 5da9b87c6a1edd22dc8f0cda0c18692b98190204..030d6ae3b8ed7810258981df984dffa6cf5e6011 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -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(); diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 7b39a06f9f3bd7c823dd1103b2d43028a4590e2a..b40c9190f65e0144672fe1ef2ea248c63e894d46 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -1,6 +1,5 @@ /* * 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) diff --git a/daemon/src/sip/sipvoiplink.h b/daemon/src/sip/sipvoiplink.h index 9a6c14eeda21f14753b40415d45b3fa6ffc8e07a..97c912a2dafc70f5d3da36b1ceea7dc7907291be 100644 --- a/daemon/src/sip/sipvoiplink.h +++ b/daemon/src/sip/sipvoiplink.h @@ -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_