diff options
author | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-26 11:55:39 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@gmail.com> | 2012-07-26 15:59:19 +0200 |
commit | bb9399e2cf0072d1de7cb0aea162d107ebde4360 (patch) | |
tree | 217696157c18ed2a291845191cc60e2b39bbf9d8 | |
parent | c55b2d0b32dd210c2a809ce2b5ebca12bfb5b1d8 (diff) |
tubes: kill double-singletonning of TeleManager
I am not sure why it was introduced in
0dae49a03c9b4816d8cdde69e30bcd2db2e30724
and hope that it's safe to remove it now.
Change-Id: I62f0ac230a83473386eabc45c9fcc387f62631e3
-rw-r--r-- | desktop/source/app/app.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/collab/contacts.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/collab/sendfunc.cxx | 4 | ||||
-rw-r--r-- | tubes/inc/tubes/manager.hxx | 13 | ||||
-rw-r--r-- | tubes/qa/test_manager.cxx | 5 | ||||
-rw-r--r-- | tubes/source/manager.cxx | 43 |
6 files changed, 12 insertions, 62 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 8582af50ba95..6d5ea30b08c2 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -624,8 +624,7 @@ Desktop::Desktop() Desktop::~Desktop() { #ifdef ENABLE_TELEPATHY - if (m_pTeleManager) - m_pTeleManager->unref(); + delete m_pTeleManager; #endif } @@ -1708,7 +1707,7 @@ int Desktop::Main() SetSplashScreenProgress(60); #ifdef ENABLE_TELEPATHY - m_pTeleManager = TeleManager::get(); + m_pTeleManager = new TeleManager(); bool bListen = rCmdLineArgs.IsInvisible(); m_pTeleManager->init( bListen ); #endif diff --git a/sc/source/ui/collab/contacts.cxx b/sc/source/ui/collab/contacts.cxx index 80cb756d095f..8529b3d7a004 100644 --- a/sc/source/ui/collab/contacts.cxx +++ b/sc/source/ui/collab/contacts.cxx @@ -170,7 +170,7 @@ public: maBtnListen( this, ScResId( BTN_LISTEN ) ), maListContainer( this, ScResId( CTL_LIST ) ), maList( maListContainer ), - mpManager( TeleManager::get() ) + mpManager( new TeleManager() ) { Hide(); maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) ); @@ -196,7 +196,7 @@ public: } virtual ~TubeContacts() { - mpManager->unref(); + delete mpManager; } static rtl::OUString fromUTF8( const char *pStr ) diff --git a/sc/source/ui/collab/sendfunc.cxx b/sc/source/ui/collab/sendfunc.cxx index a366956821ad..b78d34c1bb9e 100644 --- a/sc/source/ui/collab/sendfunc.cxx +++ b/sc/source/ui/collab/sendfunc.cxx @@ -355,9 +355,9 @@ ScDocFunc *ScDocShell::CreateDocFunc() ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this ); ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect ); ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver ); - TeleManager *pManager = TeleManager::get(); + TeleManager *pManager = new TeleManager(); pSender->SetCollaboration( pManager->getConference() ); - pManager->unref(); + delete pManager; return pSender; } else diff --git a/tubes/inc/tubes/manager.hxx b/tubes/inc/tubes/manager.hxx index 0e96826337da..163b58eb6228 100644 --- a/tubes/inc/tubes/manager.hxx +++ b/tubes/inc/tubes/manager.hxx @@ -72,11 +72,9 @@ public: /** Prepare tube manager with account and service to be offered/listened to. */ - TeleManager(); - ~TeleManager(); + TUBES_DLLPUBLIC TeleManager(); + TUBES_DLLPUBLIC ~TeleManager(); - TUBES_DLLPUBLIC static TeleManager* get(); - TUBES_DLLPUBLIC void unref(); TUBES_DLLPUBLIC bool init( bool bListen ); /** Connect to DBus and create AccountManager. */ @@ -197,13 +195,6 @@ private: static sal_uInt32 nRefCount; static rtl::OString aNameSuffix; - /* FIXME: double-singletonning is bad. These two are used by ::get and - * ::unref, and are a quick hack so that we can have a demo working. - */ - static TeleManager* pSingleton; - static sal_uInt32 nAnotherRefCount; - static ::osl::Mutex& GetAnotherMutex(); - friend class TeleManagerImpl; // access to mutex static ::osl::Mutex& GetMutex(); diff --git a/tubes/qa/test_manager.cxx b/tubes/qa/test_manager.cxx index 81298d0c48e2..f914b3331033 100644 --- a/tubes/qa/test_manager.cxx +++ b/tubes/qa/test_manager.cxx @@ -129,7 +129,7 @@ void TestTeleTubes::testInitialize() mpMainLoop = g_main_loop_new (NULL, FALSE); g_timeout_add_seconds (10, timed_out, mpMainLoop); - mpManager = TeleManager::get(); + mpManager = new TeleManager(); } void TestTeleTubes::testContactList() @@ -279,12 +279,11 @@ void TestTeleTubes::testDestroyTeleTubes() g_object_unref(mpAccepterContact); mpAccepterContact = NULL; } - if (mpManager) - mpManager->unref(); g_main_loop_unref( mpMainLoop ); if (mpConference1) mpConference1->close(); delete mpConference1; + delete mpManager; } void TestTeleTubes::testFailAlways() diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx index c60388ffd296..cfff455951c2 100644 --- a/tubes/source/manager.cxx +++ b/tubes/source/manager.cxx @@ -81,10 +81,6 @@ TeleManagerImpl* TeleManager::pImpl = NULL; sal_uInt32 TeleManager::nRefCount = 0; rtl::OString TeleManager::aNameSuffix; -sal_uInt32 TeleManager::nAnotherRefCount = 0; -TeleManager* TeleManager::pSingleton = NULL; - - /** Refcounted singleton implementation class. */ class TeleManagerImpl { @@ -390,6 +386,7 @@ TeleManager::TeleManager() : mbChannelReadyHandlerInvoked( false) { + SAL_INFO( "tubes", "TeleManager::get: count: " << nRefCount ); // The glib object types need to be initialized, else we aren't going // anywhere. g_type_init(); @@ -400,7 +397,6 @@ TeleManager::TeleManager() pImpl = new TeleManagerImpl; } - TeleManager::~TeleManager() { MutexGuard aGuard( GetMutex()); @@ -411,29 +407,7 @@ TeleManager::~TeleManager() delete pImpl; pImpl = NULL; } -} - -TeleManager * -TeleManager::get() -{ - MutexGuard aGuard( GetAnotherMutex()); - SAL_INFO( "tubes", "TeleManager::get: count: " << nAnotherRefCount ); - if (!pSingleton) - pSingleton = new TeleManager(); - - nAnotherRefCount++; - return pSingleton; -} - -void -TeleManager::unref() -{ - MutexGuard aGuard( GetAnotherMutex()); - if (nAnotherRefCount && --nAnotherRefCount == 0) { - delete pSingleton; - pSingleton = NULL; - } - SAL_INFO( "tubes", "TeleManager::unref: count: " << nAnotherRefCount ); + SAL_INFO( "tubes", "TeleManager::unref: count: " << nRefCount ); } bool TeleManager::init( bool bListen ) @@ -913,19 +887,6 @@ Mutex& TeleManager::GetMutex() return *pMutex; } -Mutex& TeleManager::GetAnotherMutex() -{ - static Mutex* pMutex = NULL; - if (!pMutex) - { - MutexGuard aGuard( Mutex::getGlobalMutex()); - if (!pMutex) - pMutex = new Mutex; - } - return *pMutex; -} - - // static void TeleManager::addSuffixToNames( const char* pName ) { |