summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-03-10 14:20:21 +0100
committerStephan Bergmann <sbergman@redhat.com>2016-03-10 14:53:19 +0100
commit0dcd3c9572f36aa1b19a8898a2378810e6251647 (patch)
tree301dfc167f58a3437f6d05bfe5854c2b01367bb6 /desktop
parent85ecc7d1dd54c20cbfc191ef4f4cf945bb59d267 (diff)
Hold DispatchWatcher by rtl::Reference
Change-Id: I2bdd63c864a5b1486f01907f9598a0c25a0f144d
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/app/dispatchwatcher.cxx14
-rw-r--r--desktop/source/app/dispatchwatcher.hxx2
-rw-r--r--desktop/source/app/officeipcthread.cxx9
-rw-r--r--desktop/source/app/officeipcthread.hxx2
4 files changed, 10 insertions, 17 deletions
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 38cd63620289..23ec0b8aeaaf 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -182,10 +182,9 @@ Mutex& DispatchWatcher::GetMutex()
// Create or get the dispatch watcher implementation. This implementation must be
// a singleton to prevent access to the framework after it wants to terminate.
-DispatchWatcher* DispatchWatcher::GetDispatchWatcher()
+rtl::Reference<DispatchWatcher> DispatchWatcher::GetDispatchWatcher()
{
- static Reference< XInterface > xDispatchWatcher;
- static DispatchWatcher* pDispatchWatcher = nullptr;
+ static rtl::Reference<DispatchWatcher> xDispatchWatcher;
if ( !xDispatchWatcher.is() )
{
@@ -193,14 +192,11 @@ DispatchWatcher* DispatchWatcher::GetDispatchWatcher()
if ( !xDispatchWatcher.is() )
{
- pDispatchWatcher = new DispatchWatcher();
-
- // We have to hold a reference to ourself forever to prevent our own destruction.
- xDispatchWatcher = static_cast< cppu::OWeakObject *>( pDispatchWatcher );
+ xDispatchWatcher = new DispatchWatcher();
}
}
- return pDispatchWatcher;
+ return xDispatchWatcher;
}
@@ -378,7 +374,7 @@ bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatchRequ
aArgs2[0].Value <<= sal_True;
Reference < XNotifyingDispatch > xDisp( xDispatcher, UNO_QUERY );
if ( xDisp.is() )
- xDisp->dispatchWithNotification( aURL, aArgs2, DispatchWatcher::GetDispatchWatcher() );
+ xDisp->dispatchWithNotification( aURL, aArgs2, DispatchWatcher::GetDispatchWatcher().get() );
else
xDispatcher->dispatch( aURL, aArgs2 );
}
diff --git a/desktop/source/app/dispatchwatcher.hxx b/desktop/source/app/dispatchwatcher.hxx
index 338a44e997ff..02cb7f35915a 100644
--- a/desktop/source/app/dispatchwatcher.hxx
+++ b/desktop/source/app/dispatchwatcher.hxx
@@ -85,7 +85,7 @@ class DispatchWatcher : public ::cppu::WeakImplHelper< css::frame::XDispatchResu
virtual void SAL_CALL dispatchFinished( const css::frame::DispatchResultEvent& aEvent ) throw( css::uno::RuntimeException, std::exception ) override;
// Access function to get a dispatcher watcher reference. There must be a global reference holder
- static DispatchWatcher* GetDispatchWatcher();
+ static rtl::Reference<DispatchWatcher> GetDispatchWatcher();
// execute new dispatch request
bool executeDispatchRequests( const DispatchList& aDispatches, bool bNoTerminate = false );
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index b672ce73d9e8..b0073a359948 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -658,8 +658,7 @@ OfficeIPCThread::OfficeIPCThread() :
Thread( "OfficeIPCThread" ),
mbDowning( false ),
mbRequestsEnabled( false ),
- mnPendingRequests( 0 ),
- mpDispatchWatcher( nullptr )
+ mnPendingRequests( 0 )
{
}
@@ -667,8 +666,7 @@ OfficeIPCThread::~OfficeIPCThread()
{
::osl::ClearableMutexGuard aGuard( GetMutex() );
- if ( mpDispatchWatcher )
- mpDispatchWatcher->release();
+ mpDispatchWatcher.clear();
maPipe.close();
pGlobalOfficeIPCThread.clear();
}
@@ -1079,10 +1077,9 @@ bool OfficeIPCThread::ExecuteCmdLineRequests( ProcessDocumentsRequest& aRequest
return bShutdown;
pGlobalOfficeIPCThread->mnPendingRequests += aDispatchList.size();
- if ( !pGlobalOfficeIPCThread->mpDispatchWatcher )
+ if ( !pGlobalOfficeIPCThread->mpDispatchWatcher.is() )
{
pGlobalOfficeIPCThread->mpDispatchWatcher = DispatchWatcher::GetDispatchWatcher();
- pGlobalOfficeIPCThread->mpDispatchWatcher->acquire();
}
// copy for execute
diff --git a/desktop/source/app/officeipcthread.hxx b/desktop/source/app/officeipcthread.hxx
index e00593dee359..b8770c69fc9a 100644
--- a/desktop/source/app/officeipcthread.hxx
+++ b/desktop/source/app/officeipcthread.hxx
@@ -76,7 +76,7 @@ class OfficeIPCThread : public salhelper::Thread
bool mbDowning;
bool mbRequestsEnabled;
int mnPendingRequests;
- DispatchWatcher* mpDispatchWatcher;
+ rtl::Reference<DispatchWatcher> mpDispatchWatcher;
/* condition to be set when the request has been processed */
::osl::Condition cProcessed;