[Libreoffice-commits] core.git: 4 commits - desktop/source
Stephan Bergmann
sbergman at redhat.com
Thu Mar 10 13:53:43 UTC 2016
desktop/source/app/app.cxx | 27 ++++++++-------------------
desktop/source/app/dispatchwatcher.cxx | 16 ++++++----------
desktop/source/app/dispatchwatcher.hxx | 10 +++-------
desktop/source/app/officeipcthread.cxx | 9 +++------
desktop/source/app/officeipcthread.hxx | 2 +-
5 files changed, 21 insertions(+), 43 deletions(-)
New commits:
commit 0827a83a776e8be6329d1aa3caa72bf19431ad08
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Mar 10 14:35:20 2016 +0100
Remove unnecessary class DispatchWatcherHashMap
Change-Id: Ie73f964651aac4571ce0ddd56b5b821669188495
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 23ec0b8..9cdbf66 100644
--- a/desktop/source/app/dispatchwatcher.cxx
+++ b/desktop/source/app/dispatchwatcher.cxx
@@ -339,7 +339,7 @@ bool DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatchRequ
{
::osl::ClearableMutexGuard aGuard( GetMutex() );
// Remember request so we can find it in statusChanged!
- m_aRequestContainer.insert( DispatchWatcherHashMap::value_type( aURL.Complete, (sal_Int32)1 ) );
+ m_aRequestContainer.emplace(aURL.Complete, 1);
m_nRequestCount++;
}
diff --git a/desktop/source/app/dispatchwatcher.hxx b/desktop/source/app/dispatchwatcher.hxx
index 02cb7f3..aa44378 100644
--- a/desktop/source/app/dispatchwatcher.hxx
+++ b/desktop/source/app/dispatchwatcher.hxx
@@ -38,11 +38,6 @@ namespace desktop
there is arose a problem. If there is none the office will be shutdown to prevent a
running office without UI.
*/
-
-class DispatchWatcherHashMap : public std::unordered_map< OUString, sal_Int32, OUStringHash, std::equal_to< OUString > >
-{
-};
-
class DispatchWatcher : public ::cppu::WeakImplHelper< css::frame::XDispatchResultListener >
{
public:
@@ -95,7 +90,8 @@ class DispatchWatcher : public ::cppu::WeakImplHelper< css::frame::XDispatchResu
static ::osl::Mutex& GetMutex();
- DispatchWatcherHashMap m_aRequestContainer;
+ std::unordered_map<OUString, sal_Int32, OUStringHash>
+ m_aRequestContainer;
sal_Int16 m_nRequestCount;
};
commit 0dcd3c9572f36aa1b19a8898a2378810e6251647
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Mar 10 14:20:21 2016 +0100
Hold DispatchWatcher by rtl::Reference
Change-Id: I2bdd63c864a5b1486f01907f9598a0c25a0f144d
diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx
index 38cd636..23ec0b8 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 338a44e..02cb7f3 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 b672ce7..b0073a3 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 e00593d..b8770c6 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;
commit 85ecc7d1dd54c20cbfc191ef4f4cf945bb59d267
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Mar 10 14:08:22 2016 +0100
ProcessDocumentsRequest ctor inits pcProcessed to null
Change-Id: I109f4acae9ac0a61004d06a82a479541f14cfd22
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 3cfd3e7..a7d97de 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2354,8 +2354,6 @@ void Desktop::OpenClients()
OfficeIPCThread::EnableRequests();
ProcessDocumentsRequest aRequest(rArgs.getCwdUrl());
- aRequest.pcProcessed = nullptr;
-
aRequest.aOpenList = rArgs.GetOpenList();
aRequest.aViewList = rArgs.GetViewList();
aRequest.aStartList = rArgs.GetStartList();
@@ -2482,7 +2480,6 @@ void Desktop::OpenDefault()
}
ProcessDocumentsRequest aRequest(rArgs.getCwdUrl());
- aRequest.pcProcessed = nullptr;
aRequest.aOpenList.push_back(aName);
OfficeIPCThread::ExecuteCmdLineRequests( aRequest );
}
@@ -2607,8 +2604,6 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
std::vector<OUString> const & data(rAppEvent.GetStringsData());
docsRequest.aOpenList.insert(
docsRequest.aOpenList.end(), data.begin(), data.end());
- docsRequest.pcProcessed = nullptr;
-
OfficeIPCThread::ExecuteCmdLineRequests(docsRequest);
}
}
@@ -2626,8 +2621,6 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
std::vector<OUString> const & data(rAppEvent.GetStringsData());
docsRequest.aPrintList.insert(
docsRequest.aPrintList.end(), data.begin(), data.end());
- docsRequest.pcProcessed = nullptr;
-
OfficeIPCThread::ExecuteCmdLineRequests(docsRequest);
}
}
commit 5a9fa5ca17073f409b8ffc13d909b218b5bcb40d
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Thu Mar 10 13:56:43 2016 +0100
No need for heap allocation here
Change-Id: I34e96e3101f80398f238cdb5a94c00fee4b0faae
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 2b4782c0..3cfd3e7 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -2603,15 +2603,13 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
const CommandLineArgs& rCmdLine = GetCommandLineArgs();
if ( !rCmdLine.IsInvisible() && !rCmdLine.IsTerminateAfterInit() )
{
- ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest(
- rCmdLine.getCwdUrl());
+ ProcessDocumentsRequest docsRequest(rCmdLine.getCwdUrl());
std::vector<OUString> const & data(rAppEvent.GetStringsData());
- pDocsRequest->aOpenList.insert(
- pDocsRequest->aOpenList.end(), data.begin(), data.end());
- pDocsRequest->pcProcessed = nullptr;
+ docsRequest.aOpenList.insert(
+ docsRequest.aOpenList.end(), data.begin(), data.end());
+ docsRequest.pcProcessed = nullptr;
- OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest );
- delete pDocsRequest;
+ OfficeIPCThread::ExecuteCmdLineRequests(docsRequest);
}
}
break;
@@ -2624,15 +2622,13 @@ void Desktop::HandleAppEvent( const ApplicationEvent& rAppEvent )
const CommandLineArgs& rCmdLine = GetCommandLineArgs();
if ( !rCmdLine.IsInvisible() && !rCmdLine.IsTerminateAfterInit() )
{
- ProcessDocumentsRequest* pDocsRequest = new ProcessDocumentsRequest(
- rCmdLine.getCwdUrl());
+ ProcessDocumentsRequest docsRequest(rCmdLine.getCwdUrl());
std::vector<OUString> const & data(rAppEvent.GetStringsData());
- pDocsRequest->aPrintList.insert(
- pDocsRequest->aPrintList.end(), data.begin(), data.end());
- pDocsRequest->pcProcessed = nullptr;
+ docsRequest.aPrintList.insert(
+ docsRequest.aPrintList.end(), data.begin(), data.end());
+ docsRequest.pcProcessed = nullptr;
- OfficeIPCThread::ExecuteCmdLineRequests( *pDocsRequest );
- delete pDocsRequest;
+ OfficeIPCThread::ExecuteCmdLineRequests(docsRequest);
}
}
break;
More information about the Libreoffice-commits
mailing list