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()
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
......
......@@ -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 )
......
......@@ -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
......
......@@ -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();
......
......@@ -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()
......
......@@ -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 )
{
......
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