diff options
Diffstat (limited to 'tubes')
-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 |
3 files changed, 6 insertions, 55 deletions
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 ) { |