Kaydet (Commit) bb9399e2 authored tarafından Matúš Kukan's avatar Matúš Kukan

tubes: kill double-singletonning of TeleManager

I am not sure why it was introduced in
0dae49a0
and hope that it's safe to remove it now.

Change-Id: I62f0ac230a83473386eabc45c9fcc387f62631e3
üst c55b2d0b
...@@ -624,8 +624,7 @@ Desktop::Desktop() ...@@ -624,8 +624,7 @@ Desktop::Desktop()
Desktop::~Desktop() Desktop::~Desktop()
{ {
#ifdef ENABLE_TELEPATHY #ifdef ENABLE_TELEPATHY
if (m_pTeleManager) delete m_pTeleManager;
m_pTeleManager->unref();
#endif #endif
} }
...@@ -1708,7 +1707,7 @@ int Desktop::Main() ...@@ -1708,7 +1707,7 @@ int Desktop::Main()
SetSplashScreenProgress(60); SetSplashScreenProgress(60);
#ifdef ENABLE_TELEPATHY #ifdef ENABLE_TELEPATHY
m_pTeleManager = TeleManager::get(); m_pTeleManager = new TeleManager();
bool bListen = rCmdLineArgs.IsInvisible(); bool bListen = rCmdLineArgs.IsInvisible();
m_pTeleManager->init( bListen ); m_pTeleManager->init( bListen );
#endif #endif
......
...@@ -170,7 +170,7 @@ public: ...@@ -170,7 +170,7 @@ public:
maBtnListen( this, ScResId( BTN_LISTEN ) ), maBtnListen( this, ScResId( BTN_LISTEN ) ),
maListContainer( this, ScResId( CTL_LIST ) ), maListContainer( this, ScResId( CTL_LIST ) ),
maList( maListContainer ), maList( maListContainer ),
mpManager( TeleManager::get() ) mpManager( new TeleManager() )
{ {
Hide(); Hide();
maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) ); maBtnConnect.SetClickHdl( LINK( this, TubeContacts, BtnConnectHdl ) );
...@@ -196,7 +196,7 @@ public: ...@@ -196,7 +196,7 @@ public:
} }
virtual ~TubeContacts() virtual ~TubeContacts()
{ {
mpManager->unref(); delete mpManager;
} }
static rtl::OUString fromUTF8( const char *pStr ) static rtl::OUString fromUTF8( const char *pStr )
......
...@@ -355,9 +355,9 @@ ScDocFunc *ScDocShell::CreateDocFunc() ...@@ -355,9 +355,9 @@ ScDocFunc *ScDocShell::CreateDocFunc()
ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this ); ScDocFuncDirect *pDirect = new ScDocFuncDirect( *this );
ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect ); ScDocFuncRecv *pReceiver = new ScDocFuncRecv( pDirect );
ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver ); ScDocFuncSend *pSender = new ScDocFuncSend( *this, pReceiver );
TeleManager *pManager = TeleManager::get(); TeleManager *pManager = new TeleManager();
pSender->SetCollaboration( pManager->getConference() ); pSender->SetCollaboration( pManager->getConference() );
pManager->unref(); delete pManager;
return pSender; return pSender;
} }
else else
......
...@@ -72,11 +72,9 @@ public: ...@@ -72,11 +72,9 @@ public:
/** Prepare tube manager with account and service to be offered/listened /** Prepare tube manager with account and service to be offered/listened
to. to.
*/ */
TeleManager(); TUBES_DLLPUBLIC TeleManager();
~TeleManager(); TUBES_DLLPUBLIC ~TeleManager();
TUBES_DLLPUBLIC static TeleManager* get();
TUBES_DLLPUBLIC void unref();
TUBES_DLLPUBLIC bool init( bool bListen ); TUBES_DLLPUBLIC bool init( bool bListen );
/** Connect to DBus and create AccountManager. */ /** Connect to DBus and create AccountManager. */
...@@ -197,13 +195,6 @@ private: ...@@ -197,13 +195,6 @@ private:
static sal_uInt32 nRefCount; static sal_uInt32 nRefCount;
static rtl::OString aNameSuffix; 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 friend class TeleManagerImpl; // access to mutex
static ::osl::Mutex& GetMutex(); static ::osl::Mutex& GetMutex();
......
...@@ -129,7 +129,7 @@ void TestTeleTubes::testInitialize() ...@@ -129,7 +129,7 @@ void TestTeleTubes::testInitialize()
mpMainLoop = g_main_loop_new (NULL, FALSE); mpMainLoop = g_main_loop_new (NULL, FALSE);
g_timeout_add_seconds (10, timed_out, mpMainLoop); g_timeout_add_seconds (10, timed_out, mpMainLoop);
mpManager = TeleManager::get(); mpManager = new TeleManager();
} }
void TestTeleTubes::testContactList() void TestTeleTubes::testContactList()
...@@ -279,12 +279,11 @@ void TestTeleTubes::testDestroyTeleTubes() ...@@ -279,12 +279,11 @@ void TestTeleTubes::testDestroyTeleTubes()
g_object_unref(mpAccepterContact); g_object_unref(mpAccepterContact);
mpAccepterContact = NULL; mpAccepterContact = NULL;
} }
if (mpManager)
mpManager->unref();
g_main_loop_unref( mpMainLoop ); g_main_loop_unref( mpMainLoop );
if (mpConference1) if (mpConference1)
mpConference1->close(); mpConference1->close();
delete mpConference1; delete mpConference1;
delete mpManager;
} }
void TestTeleTubes::testFailAlways() void TestTeleTubes::testFailAlways()
......
...@@ -81,10 +81,6 @@ TeleManagerImpl* TeleManager::pImpl = NULL; ...@@ -81,10 +81,6 @@ TeleManagerImpl* TeleManager::pImpl = NULL;
sal_uInt32 TeleManager::nRefCount = 0; sal_uInt32 TeleManager::nRefCount = 0;
rtl::OString TeleManager::aNameSuffix; rtl::OString TeleManager::aNameSuffix;
sal_uInt32 TeleManager::nAnotherRefCount = 0;
TeleManager* TeleManager::pSingleton = NULL;
/** Refcounted singleton implementation class. */ /** Refcounted singleton implementation class. */
class TeleManagerImpl class TeleManagerImpl
{ {
...@@ -390,6 +386,7 @@ TeleManager::TeleManager() ...@@ -390,6 +386,7 @@ TeleManager::TeleManager()
: :
mbChannelReadyHandlerInvoked( false) mbChannelReadyHandlerInvoked( false)
{ {
SAL_INFO( "tubes", "TeleManager::get: count: " << nRefCount );
// The glib object types need to be initialized, else we aren't going // The glib object types need to be initialized, else we aren't going
// anywhere. // anywhere.
g_type_init(); g_type_init();
...@@ -400,7 +397,6 @@ TeleManager::TeleManager() ...@@ -400,7 +397,6 @@ TeleManager::TeleManager()
pImpl = new TeleManagerImpl; pImpl = new TeleManagerImpl;
} }
TeleManager::~TeleManager() TeleManager::~TeleManager()
{ {
MutexGuard aGuard( GetMutex()); MutexGuard aGuard( GetMutex());
...@@ -411,29 +407,7 @@ TeleManager::~TeleManager() ...@@ -411,29 +407,7 @@ TeleManager::~TeleManager()
delete pImpl; delete pImpl;
pImpl = NULL; pImpl = NULL;
} }
} SAL_INFO( "tubes", "TeleManager::unref: count: " << nRefCount );
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 );
} }
bool TeleManager::init( bool bListen ) bool TeleManager::init( bool bListen )
...@@ -913,19 +887,6 @@ Mutex& TeleManager::GetMutex() ...@@ -913,19 +887,6 @@ Mutex& TeleManager::GetMutex()
return *pMutex; return *pMutex;
} }
Mutex& TeleManager::GetAnotherMutex()
{
static Mutex* pMutex = NULL;
if (!pMutex)
{
MutexGuard aGuard( Mutex::getGlobalMutex());
if (!pMutex)
pMutex = new Mutex;
}
return *pMutex;
}
// static // static
void TeleManager::addSuffixToNames( const char* pName ) void TeleManager::addSuffixToNames( const char* pName )
{ {
......
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